I’ve just started to use dataGridView, and some things seem strange to me:
- when there is a Columns property, in which you can add columns, why is there not a Rows property? It seems you can only add rows programmatically. Or am I wrong?
- the ‘star’ icon to the left of the first row, can’t it be removed?
- is it possible to disable sorting? I mean when you click on a column, the “sorting-arrow” appears, suggesting that the cells would be sorted.
If it is only possible to add rows programmatically, I have this question:
- I need a dataGridView with 1 column and x rows. How to do this the quickest and easiest way? The cells will be filled at runtime, programmatically.
update: About disabling sorting, I found out myself: there is a property to change this if you open the (Collections) of the columns.
You can add Rows by calling
dataGridView1.Rows.Add();. For multiple rows there is an overload for the same available.dataGridView1.Rows.Add(5);Now to fill the
dataGridView1rows you can either assign a DataSource and set theDataPropertyNamefor the Column.Else loop through and fill the data cell wise like
dataGridView1[columnindex,rowindex].Value =somethingThe star icon shows the current row which is being edited, you can choose to hide that cell by setting the
RowHeadersVisibleto false.