Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7418809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:57:07+00:00 2026-05-29T07:57:07+00:00

I am using WPF Data-grid with auto-generated columns. I am assigning data-table with one

  • 0

I am using WPF Data-grid with auto-generated columns. I am assigning data-table with one column but no rows as Items-source.

public DataTable GetInitData()
    {
        empDS = new DataSet();
        empTbl = new DataTable();
        empDS.Tables.Add(empTbl);
        dc = new DataColumn("Test");
        empDS.Tables[0].Columns.Add(dc);
        empDS.AcceptChanges();
        return empDS.Tables[0];
    }

and I call the method above in the constructor.

 public MainWindow()
    {
        this.InitializeComponent();
        this.grdEmp.ItemsSource = this.GetInitData().DefaultView;
    }

Screen-shot:

Screen shot of window

Now when I press F5 and run the code… the Data-grid doesn’t show any column. Please guide me, why it is not showing any column. If you need any other information do let me know.

Regards,
Priyank

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T07:57:09+00:00Added an answer on May 29, 2026 at 7:57 am

    If you add a single row to your table you will see the column generated. Therefore, I can only suggest this is a limitation (bug?) in the WPF DataGrid. Depending on what you’re trying to achieve, you might like to add an empty row to your data first.

    public DataTable GetInitData()
    {
        var empDS = new DataSet();
        var empTbl = new DataTable();
        empDS.Tables.Add(empTbl);
        var dc = new DataColumn("Test");
        empDS.Tables[0].Columns.Add(dc);
        var row = empDS.Tables[0].NewRow();
        //row[0] = "foo";
        empDS.Tables[0].Rows.Add(row);
        empDS.AcceptChanges();
        return empDS.Tables[0];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am assigning a datatable with multiple columns and zero rows to WPF data-grid.
I am using wpf data grid which has template columns. i just want to
I have a WPF Datagrid populated with data from one SQL table using Entity
I am using WPF datagrid. Data I am binding to the grid is not
I am trying to do data binding in WPF on a data grid using
I am currently populating my WPF grid using a data collection that implements ITypedList
I'm using WPF. On my window there is a data grid which binding with
I have a .Net 4.0 WPF application using a data grid. Currently after sorting
I'm using a WPF data grid to bind to an object (i.e. not a
I have a situation where I am using wpf data binding and validation using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.