How to set a text and focus on form load in grid dynamic filter bar cell in WinForms GridGroupingControl?
Customize the filter bar
In order to
set the text and focus on FilterBarCell on form load, CurrentCell.Activate method
in DrawCellDisplayText events can be used.
C#
FilterCondition condition = new FilterCondition(FilterCompareOperator.Like, "Sample data1");
// Add the condition to the specific column
RecordFilterDescriptor rf = new RecordFilterDescriptor("Sample Test", condition);
// Add the RecordFilterDescriptor to the RecordFilters
this.gridGroupingControl1.TableDescriptor.RecordFilters.Add(rf);
// Changing FilterBar display text
private void gridGroupingControl1_TableControlDrawCellDisplayText(object sender, GridTableControlDrawCellDisplayTextEventArgs e)
{
GridTableCellStyleInfo style = this.gridGroupingControl1.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex);
if (e.Inner.ColIndex == 1)
{
if (style.TableCellIdentity.TableCellType == GridTableCellType.FilterBarCell)
{
e.Inner.DisplayText = "Dynamic Filter";
// Activate the CurrentCell on the FilterBar cell using (RowIndex, ColIndex)
e.TableControl.CurrentCell.Activate(e.Inner.RowIndex, e.Inner.ColIndex);
}
}
}VB
Dim condition As New FilterCondition(FilterCompareOperator.Like, "Sample data1")
' Add the Condition to the particular Column.
Dim rf As New RecordFilterDescriptor("Sample Test", condition)
' Add the RecordFilterDescriptor to the RecordFilters.
Me.gridGroupingControl1.TableDescriptor.RecordFilters.Add(rf)
' changing FilaterBar Display Text.
Private Sub gridGroupingControl1_TableControlDrawCellDisplayText(ByVal sender As Object, ByVal e As GridTableControlDrawCellDisplayTextEventArgs)
Dim style As GridTableCellStyleInfo = Me.gridGroupingControl1.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex)
If e.Inner.ColIndex = 1 Then
If style.TableCellIdentity.TableCellType = GridTableCellType.FilterBarCell Then
e.Inner.DisplayText = "Dynamic Filter"
'Activate the CurrentCell on the Filterbar cell using (RowIndex,ColIndex)
e.TableControl.CurrentCell.Activate(e.Inner.RowIndex, e.Inner.ColIndex)
End If
End If
End SubThe screenshot below illustrates before setting the Filter bar

The screenshot below illustrates after setting the Filter bar

Samples:
Reference Link: Dynamic filter