Articles in this section
Category / Section

How to set a text and focus on form load in grid dynamic filter bar cell in WinForms GridGroupingControl?

1 min read

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#

// changing FilaterBar Display Text.
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 = "Dyanmic 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 Sub

 

Screenshot

Before

Before customize the filter bar cell in GridGroupingControl

After

 

After customize the filter bar cell in GridGroupingControl

 

Samples:

C#: Customize FilterBar_CS

VB: Customize FilterBar_VB

Reference link: https://help.syncfusion.com/windowsforms/classic/gridgroupingcontrol/filtering#dynamic-filter

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied