作成日: 2019/12/10 最終更新日: 2019/12/10
文書種別
使用方法
詳細
C1FlexGridFilter拡張クラスを使用したフィルタ機能のエディタの「適用」「リセット」「キャンセル」ボタンは、下記のサンプルコードのように、C1FlexGridFilterのEditorOpenedイベントでボタンを取得して、対応するボタンの押下イベントを追加することが可能です。
◎サンプルコード(C#)
◎サンプルコード(C#)
using C1.WPF.FlexGrid;
public partial class MainWindow : Window
{
Button filter_Apply;
Button filter_Clear;
Button filter_Cancel;
public MainWindow()
{
InitializeComponent();
var gridFilter = new C1FlexGridFilter(c1FlexGrid1);
gridFilter.EditorOpened += GridFilter_EditorOpened;
gridFilter.EditorClosed += GridFilter_EditorClosed;
}
private void GridFilter_EditorOpened(object sender, EventArgs e)
{
C1FlexGridFilter filter = (C1FlexGridFilter)sender;
filter_Apply = FindChild<Button>(filter.Editor, "_btnApply");
filter_Clear = FindChild<Button>(filter.Editor, "_btnClear");
filter_Cancel = FindChild<Button>(filter.Editor, "_btnCancel");
filter_Apply.Click += Filter_Apply_Click;
filter_Clear.Click += Filter_Clear_Click;
filter_Cancel.Click += Filter_Cancel_Click;
}
private void GridFilter_EditorClosed(object sender, EventArgs e)
{
filter_Apply.Click -= Filter_Apply_Click;
filter_Clear.Click -= Filter_Clear_Click;
filter_Cancel.Click -= Filter_Cancel_Click;
}
private void Filter_Cancel_Click(object sender, RoutedEventArgs e)
{
System.Diagnostics.Debug.WriteLine("Cancel Clicked");
}
private void Filter_Clear_Click(object sender, RoutedEventArgs e)
{
System.Diagnostics.Debug.WriteLine("Clear Clicked");
}
private void Filter_Apply_Click(object sender, RoutedEventArgs e)
{
System.Diagnostics.Debug.WriteLine("Apply Clicked");
}
public static T FindChild<T>(DependencyObject parent, string childName)
where T : DependencyObject
{
if (parent == null) return null;
T foundChild = null;
int childrenCount = VisualTreeHelper.GetChildrenCount(parent);
for (int i = 0; i < childrenCount; i++)
{
var child = VisualTreeHelper.GetChild(parent, i);
T childType = child as T;
if (childType == null)
{
foundChild = FindChild(child, childName);
if (foundChild != null) break;
}
else if (!string.IsNullOrEmpty(childName))
{
var frameworkElement = child as FrameworkElement;
if (frameworkElement != null && frameworkElement.Name == childName)
{
foundChild = (T)child;
break;
}
}
else
{
foundChild = (T)child;
break;
}
}
return foundChild;
}
}
public partial class MainWindow : Window
{
Button filter_Apply;
Button filter_Clear;
Button filter_Cancel;
public MainWindow()
{
InitializeComponent();
var gridFilter = new C1FlexGridFilter(c1FlexGrid1);
gridFilter.EditorOpened += GridFilter_EditorOpened;
gridFilter.EditorClosed += GridFilter_EditorClosed;
}
private void GridFilter_EditorOpened(object sender, EventArgs e)
{
C1FlexGridFilter filter = (C1FlexGridFilter)sender;
filter_Apply = FindChild<Button>(filter.Editor, "_btnApply");
filter_Clear = FindChild<Button>(filter.Editor, "_btnClear");
filter_Cancel = FindChild<Button>(filter.Editor, "_btnCancel");
filter_Apply.Click += Filter_Apply_Click;
filter_Clear.Click += Filter_Clear_Click;
filter_Cancel.Click += Filter_Cancel_Click;
}
private void GridFilter_EditorClosed(object sender, EventArgs e)
{
filter_Apply.Click -= Filter_Apply_Click;
filter_Clear.Click -= Filter_Clear_Click;
filter_Cancel.Click -= Filter_Cancel_Click;
}
private void Filter_Cancel_Click(object sender, RoutedEventArgs e)
{
System.Diagnostics.Debug.WriteLine("Cancel Clicked");
}
private void Filter_Clear_Click(object sender, RoutedEventArgs e)
{
System.Diagnostics.Debug.WriteLine("Clear Clicked");
}
private void Filter_Apply_Click(object sender, RoutedEventArgs e)
{
System.Diagnostics.Debug.WriteLine("Apply Clicked");
}
public static T FindChild<T>(DependencyObject parent, string childName)
where T : DependencyObject
{
if (parent == null) return null;
T foundChild = null;
int childrenCount = VisualTreeHelper.GetChildrenCount(parent);
for (int i = 0; i < childrenCount; i++)
{
var child = VisualTreeHelper.GetChild(parent, i);
T childType = child as T;
if (childType == null)
{
foundChild = FindChild
if (foundChild != null) break;
}
else if (!string.IsNullOrEmpty(childName))
{
var frameworkElement = child as FrameworkElement;
if (frameworkElement != null && frameworkElement.Name == childName)
{
foundChild = (T)child;
break;
}
}
else
{
foundChild = (T)child;
break;
}
}
return foundChild;
}
}
旧文書番号
84721