How to localize dynamic filter keywords in WinForms GridGrouping?
Localize the dynamic filter keyword
In the dynamic filter, the keywords of the compare operator are localized properly when you use ILocalization provider but the keyword ‘Expression Match…’ is not localized because this is added manually by using CreateCompareOperatorList event in the source. You can localize it by some customized way using WinForms Grid
Solution
This problem can be achieved by handling TableControlCurrentCellShowingDropDown, TableControlCellButtonClicked, CloseUp events. Refer to the following code examples.
C#
int buttonIndex = 0; void gridGroupingControl1_TableControlCellButtonClicked(object sender, GridTableControlCellButtonClickedEventArgs e) { //Identifies the button index(Compare Operator Button) buttonIndex = e.Inner.ButtonIndex; } void gridGroupingControl1_TableControlCurrentCellShowingDropDown(object sender, GridTableControlCurrentCellShowingDropDownEventArgs e) { if (e.TableControl.CurrentCell.Renderer is GridTableFilterBarExtCellRenderer) { GridTableFilterBarExtCellRenderer rend = e.TableControl.CurrentCell.Renderer as GridTableFilterBarExtCellRenderer; var s = rend.ListBoxPart.Items; if (this.checkBox5.Checked && buttonIndex == 1) { rend.DropDownContainer.CloseUp += new PopupClosedEventHandler(DropDownContainer_CloseUp); rend.ListBoxPart.Items[10] = "expresión de coincidencia"; //Specifies your needed localization string } } } void DropDownContainer_CloseUp(object sender, PopupClosedEventArgs e) { if (buttonIndex == 1) { if (this.gridGroupingControl1.TableControl.CurrentCell.Renderer is GridTableFilterBarExtCellRenderer) { GridTableFilterBarExtCellRenderer rend = this.gridGroupingControl1.TableControl.CurrentCell.Renderer as GridTableFilterBarExtCellRenderer; if (this.checkBox5.Checked && buttonIndex == 1) { if (rend.ListBoxPart.SelectedIndex == 10) { object value = "Expression Match..."; //Returns the correct value while closing the dropdown container rend.ListBoxPart.Items[10] = value; } } } } }
VB
Private buttonIndex As Integer = 0 Private Sub gridGroupingControl1_TableControlCellButtonClicked(ByVal sender As Object, ByVal e As GridTableControlCellButtonClickedEventArgs) 'Identifies the button index(Compare Operator Button) buttonIndex = e.Inner.ButtonIndex End Sub Private Sub gridGroupingControl1_TableControlCurrentCellShowingDropDown(ByVal sender As Object, ByVal e As GridTableControlCurrentCellShowingDropDownEventArgs) If TypeOf e.TableControl.CurrentCell.Renderer Is GridTableFilterBarExtCellRenderer Then Dim rend As GridTableFilterBarExtCellRenderer = TryCast(e.TableControl.CurrentCell.Renderer, GridTableFilterBarExtCellRenderer) Dim s = rend.ListBoxPart.Items If Me.checkBox5.Checked AndAlso buttonIndex = 1 Then AddHandler rend.DropDownContainer.CloseUp, AddressOf DropDownContainer_CloseUp rend.ListBoxPart.Items(10) = "expresión de coincidencia" 'Specifies your needed localization string End If End If End Sub Private Sub DropDownContainer_CloseUp(ByVal sender As Object, ByVal e As PopupClosedEventArgs) If buttonIndex = 1 Then If TypeOf Me.gridGroupingControl1.TableControl.CurrentCell.Renderer Is GridTableFilterBarExtCellRenderer Then Dim rend As GridTableFilterBarExtCellRenderer = TryCast(Me.gridGroupingControl1.TableControl.CurrentCell.Renderer, GridTableFilterBarExtCellRenderer) If Me.checkBox5.Checked AndAlso buttonIndex = 1 Then If rend.ListBoxPart.SelectedIndex = 10 Then Dim value As Object = "Expression Match..." 'Returns the correct value while closing the dropdown container rend.ListBoxPart.Items(10) = value End If End If End If End If End Sub
Conclusion
I hope you enjoyed learning how to localize dynamic filter keywords in WinForms GridGrouping.
You can refer to WinForms GridGrouping feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WinForms GridGrouping example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!