How to Create a Custom Data Row Element in RadGridView
Environment
Product Version | Product | Author |
---|---|---|
2022.1.222 | RadGridView for WinForms | Desislava Yordanova |
Description
This article demonstrates a sample approach how to create a custom data row element that contains a label stretched among the entire row. Then, display this row at a certain index, e.g. 4, in RadGridView and keep the rest of the rows with the default cells layout.
Solution
One common visual row element is used for all the data rows which is returned by the GridViewDataRowInfo.RowElementType property. That is why you can't use one row element for the row at index 4 and another visual row element for the rest of the data rows. The suitable approach here is to create a common custom row element (typeof(GridDataRowElement)) that contains the desired label and simply show/hide it for the respective rows.
The RadLabelElement can be replaced with any other RadElement according to the custom requirement that has to be accomplished.
Use the RadGridView.CreateRowInfo event to replace the data row.