Here my code to create a data table. I must display the columns at form load and even when there is no data so that the user knows what to expect in the dataGridView control... so i have designed the columns for that dataGridView from designer and i have aslo designer the columns for the DataTable from code:
here is my code:
|
But it displays an empty Grid:
Why this happense?
thanks
PS: I have attached the code if required to have a look at it :)
Hirendra SisodiyaPosted Mar 16, 2010, 2:19 AM
DataGridView1.AutoGenerateColumns = False;
modify this as
DataGridView1.AutoGenerateColumns = True;
thank you
Please mark as answere, if you like this answere.
petre ricardoPosted Mar 16, 2010, 2:06 AM
Amit ChoudharyPosted Mar 16, 2010, 1:04 AM
try this trick
dataGridView1.DataSource = dt.DefaultView;
It'll work fine i have already solved this problem using this trick.
Please mark as answer if it helps.