gosr
gosr

Reputation: 4708

C# WinForms: Adding rows to a dataGridView

I've just started to use dataGridView, and some things seem strange to me:

If it is only possible to add rows programmatically, I have this question:

update: About disabling sorting, I found out myself: there is a property to change this if you open the (Collections) of the columns.

Upvotes: 0

Views: 9763

Answers (1)

V4Vendetta
V4Vendetta

Reputation: 38230

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 dataGridView1 rows you can either assign a DataSource and set the DataPropertyName for the Column. Else loop through and fill the data cell wise like dataGridView1[columnindex,rowindex].Value =something

The star icon shows the current row which is being edited, you can choose to hide that cell by setting the RowHeadersVisible to false.

Upvotes: 4

Related Questions