How to Indicate RadTextBoxEditor in Grid Filter Cells
Environment
Product Version | Product | Author |
---|---|---|
2022.1.222 | RadGridView for WinForms | Desislava Yordanova |
Description
RadGridView uses an editing mechanism which means that when you need to edit a single cell, an appropriate editor is activated. Once the editor's value is confirmed (e.g. by pressing Enter), the value is committed to the respective cell. The same approach is followed for the filter cells. Only a single cell can be in edit mode at a time. That is why the textbox is not visible until the filter cell enters edit mode.
Normal state | Edit mode |
---|---|
![]() |
![]() |
A common requirement is to indicate the editor in the filter cells even though the grid is not in edit mode. This article demonstrates a sample approach how to indicate the RadTextBoxEditor in the filter cells for the GridViewTextBoxColumn. However, this approach can be adopted for other column types as well.
Solution
We will use a RadGridView bound to the Northwind.Products table. Then, we will replace the "ProductName" column with a custom one.
1. Create a derivative of GridFilterCellElement and add a RadTextBoxControlElement to it which will be visible only when the filter cell is NOT in edit mode. Once the editor is activated, the RadTextBoxControlElement will be collapsed. Its purpose is to indicate the end users that there is a textbox editor for filtering.
2. Create a derivative of GridViewTextBoxColumn and replace the default GridFilterCellElement with the custom one in the GetCellType method.
The achieved result is illustrated below: