After columns are added and configured, rows may be added.

1. Adding rows

Rows may be added in several ways. Most common way is by using AddRow method.

Since AddRow method return reference to newly added row, handy Fill() method may be used to set initial values for cells inside this row.

nextGrid1.AddRow().Fill( new int[] { 0, 2 }, new object[] { 3.14, textBox1.Text } );
First parameter (array) represent column indexes, and second (also array) represent values.

There is also overloaded version of AddRow which include count parameter. This parameter specifies number of rows to be added at the end of rows array.

nextGrid1.AddRow(5); nextGrid1.AddRow(1000);

2. Deleting rows

After row is added, it may be deleted by calling DeleteRow method.

nextGrid1.DeleteRow(2); // delete 3rd row in array nextGrid1.DeleteRow(nextGrid1.SelectedRow);
To access single row (and its properties) use nextGrid indexer.

nextGrid1[rowIndex].Height = 20; // Change height of row nextGrid1[rowIndex].Visible = false; // Hide row if (nextGrid1[rowIndex].IsTopLevel) { MessageBox.Show("Top level row"); }

3. Cells

As soon rows are added, you may access single cells. Every cell is a object with own properties and method.

Most important property is Value.

nextGrid1["MyColumnName", 4].Value = "none";

See also