This topic discusses various basic operations which can be performed on a row in True DBGrid, such as adding, deleting and inserting a row.
True DBGrid provides various ways to add a new row at runtime. In case of unbound mode, you can set any integer value in Count parameter of the AddRow property in C1TrueDBGrid class to set the number of rows to be displayed in the grid.
Use the code below to add rows to the WinForms True DBGrid in both unbound and bound modes.
To delete the current row from the grid, you can use the Delete method of the C1TrueDBGrid class. You can also remove the row from a specified index using RemoveAt method.
Following code gives different approaches to delete row from the WinForms True DBGrid.
C# |
コードのコピー
|
---|---|
if (c1TruedbGrid1.Rows.Count > 0) { // Approach 1 c1TruedbGrid1.Delete(); // Approach 2 c1TruedbGrid1.Rows.RemoveAt(c1TruedbGrid1.Row); } |
To insert a row in True DBGrid at a specific location, you can use the NewRow method in Frame class. You can also use the InsertAt method of DataRowCollection class to insert a row at a particular index in the grid.
Below code demonstrates how to insert a row at a particular position in the WinForms True DBGrid.
C# |
コードのコピー
|
---|---|
// Approach 1 var row = c1TruedbGrid1.NewRow(); // Approach 2 c1TruedbGrid1.Rows.InsertAt(row,c1TruedbGrid1.Row); |