Datagridview

R

R.A.F.

Hi,

I have a really stupid question about DataGridView.
how dynamically create and display it on the form ?

i tried :

DataGridView myGrid = new DataGridView();
myGrid.Columns.Add("col1", "Column 1");
myGrid.Show();

but it does not work, so i miss something, but what ?
i've read the documentation but i did not find something :-(

thanks a lot,

RAF
 
R

R.A.F.

Ok...as i told...it's stupid question...
i forgot to add line :

Control.Add(myGrid);

:)
 
N

Nicholas Paldino [.NET/C# MVP]

RAF,

You aren't binding any data to the grid, so it won't show anything. You
have to bind a data source to the grid.
 
N

Nicholas Paldino [.NET/C# MVP]

Well, for the grid to be practical, it will be necessary to bind SOME
sort of data to it. It wasn't clear from your original post whether you
were adding the grid to the controls or not, or if it was because you
weren't seeing any data.
 
R

R.A.F.

so sorry if it was not clear... for sure i will add data but not
necessary from database or table.
:)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top