This topic discusses various basic operations which can be performed on a row.
When grid is bound to a data source, the number of rows is determined by the number of records available in the data source. However, in the case of unbound mode, you can set any integer value in Count property of the RowCollection class to set the number of rows to be displayed in the grid.
Use the code below to set row count in the WinForms FlexGrid.
FlexGrid provides various ways to add a new row at runtime. You can either use Add method of the RowCollection class or AddItem method of the C1FlexGrid class to add a new record. In the unbound mode, you can also increment the value of Count property to add new rows. Note that all these ways add rows towards the end of the grid. To insert a row at a specific location, see Insert Row. Also, note that an exception is thrown if a new row is added to a bound grid using Count property.
Add a row to WinForms FlexGrid using any of these approaches shown in the code below.
To delete a particular row from the grid, you can use Remove method of the RowCollection class and specify the row you want to delete as its parameter. The RowCollection class also provides RemoveRange method which allows you to remove a range of rows using a single call. Similarly, you can also use RemoveItem method of the C1FlexGrid class to remove a specific row. In the unbound grid, you can reduce the number of rows by changing the value of Count property.
Following code gives different approaches to delete row from the WinForms FlexGrid.
To insert a row in FlexGrid at a specific location, you can use Insert method of the RowCollection class which lets you specify the position where rows are to be inserted. You can also insert multiple rows in the grid by using the InsertRange method.
Below code demonstrates how to insert a row at a particular position in the WinForms FlexGrid.
In case of a bound FlexGrid, data type of each bound column is automatically picked from the data source depending on the data. However, in the case of unbound mode, you can set the data type of rows or columns by specifying the DataType property of Row or Column class respectively. Note that when data type is set for both rows and columns, column settings take preference over row settings.
Use the code below to set data type of a WinForms FlexGrid row.
Fixed rows refer to the rows with non-editable cells which are always visible on top of the grid even when user scrolls down the grid. In FlexGrid, fixed rows can be set using Fixed property of the RowCollection class. This property accepts an integer value that specifies the number of rows to be fixed.
Set fixed rows in the WinForms FlexGrid using the code below.
Frozen rows, similar to fixed rows, are non-scrollable but can be edited by the user. In FlexGrid, frozen rows can be set by using Frozen property provided by the RowCollection class.
Use the code below to set frozen rows in the WinForms FlexGrid.