Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
149347 | Nov 22,2019 11:23 AM UTC | Nov 25,2019 01:00 PM UTC | WPF | 1 |
![]() |
Tags: SfDataGrid |
this.dataGrid.FilterItemsPopulating += DataGrid_FilterItemsPopulating;
private void OnDataGrid_FilterItemsPopulating(object sender, GridFilterItemsPopulatingEventArgs e)
{
var filterControl = e.FilterControl;
CheckboxFilterControl checkBoxFilterControl = (CheckboxFilterControl)filterControl.GetType().GetField("CheckboxFilterControl", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(filterControl);
checkBoxFilterControl.Loaded += OnCheckBoxFilterControl_Loaded;
}
void OnCheckBoxFilterControl_Loaded(object sender, RoutedEventArgs e)
{
CheckboxFilterControl checkBoxFilterControl = sender as CheckboxFilterControl;
TextBox searchTextBox = (TextBox)checkBoxFilterControl.GetType().GetField("SearchTextBox", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(checkBoxFilterControl);
if (searchTextBox != null)
{
searchTextBox.PreviewTextInput += OnSearchTextBox_PreviewTextInput;
}
}
private void OnSearchTextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
e.Handled = !IsTextAllowed(e.Text, @"[^a-zA-Z]");
}
private static bool IsTextAllowed(string Text, string AllowedRegex)
{
try
{
var regex = new Regex(AllowedRegex);
return !regex.IsMatch(Text);
}
catch
{
return true;
}
}
|
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.