I have one datagridview in my windows form. That is filling data from database based on selected value in the combo-box. For some selected item there is record in the database. for some there is no records. At that time i need to maintain a fixed size datagridview with no records filled in it. Is there any way to do this. If yes please help me…
Share
If your datasource looks similar to this:
-you may simply do this:
“sourceItems” is the internal list of items of the type “SomeClass”.
There are many ways to do this and this is just one of them.
What you are doing today is to load data from database and write the result directly to datagridview. What I suggest is that you load data from database (as you do now) and instead of writing data to datagrid, you create a class to hold the items (a datasource class). That class is then given to the datagrid similar to this:
Then use the BindingSource to controll the contents (just to show some of the things you may do):