[GcSpreadGrid] コーナーヘッダの三角のマークを非表示にする方法

文書番号 : 85102     文書種別 : 使用方法     登録日 : 2020/05/21     最終更新日 : 2020/05/21
文書を印刷する
対象製品
SPREAD for WPF 3.0J
詳細
コーナーヘッダに表示されているインジケータ(三角のマーク)は、下記のコードを実装することで、非表示にすることが可能です。

◎サンプルコード(VB)
Imports GrapeCity.Windows.SpreadGrid.Presenters

Class MainWindow
    Private Sub Window_Loaded(sender As Object, e As RoutedEventArgs)
        EventManager.RegisterClassHandler(GetType(CornerHeaderCellPresenter), Control.LoadedEvent, New RoutedEventHandler(AddressOf OnCornerHeaderLoaded))
    End Sub

    Private Shared Sub OnCornerHeaderLoaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
        Dim corner As CornerHeaderCellPresenter = TryCast(sender, CornerHeaderCellPresenter)
        If corner IsNot Nothing AndAlso VisualTreeHelper.GetChildrenCount(corner) > 0 Then
            Dim grid = TryCast(VisualTreeHelper.GetChild(corner, 0), Grid)
            If grid IsNot Nothing Then
                Dim count = VisualTreeHelper.GetChildrenCount(grid)
                For i As Integer = 0 To count - 1
                    Dim path = TryCast(VisualTreeHelper.GetChild(grid, i), System.Windows.Shapes.Path)
                    If path IsNot Nothing Then
                        path.Visibility = Visibility.Hidden
                    End If
                Next
            End If
        End If
    End Sub
End Class
◎サンプルコード(C#)
using GrapeCity.Windows.SpreadGrid.Presenters;

    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            EventManager.RegisterClassHandler(typeof(CornerHeaderCellPresenter), Control.LoadedEvent, new RoutedEventHandler(OnCornerHeaderLoaded));
        }

        private static void OnCornerHeaderLoaded(object sender, RoutedEventArgs e)
        {
            CornerHeaderCellPresenter corner = sender as CornerHeaderCellPresenter;
            if (corner != null && VisualTreeHelper.GetChildrenCount(corner) > 0)
            {
                var grid = VisualTreeHelper.GetChild(corner, 0) as Grid;
                if (grid != null)
                {
                    var count = VisualTreeHelper.GetChildrenCount(grid);
                    for (int i = 0; i < count; i++)
                    {
                        var path = VisualTreeHelper.GetChild(grid, i) as System.Windows.Shapes.Path;
                        if (path != null)
                        {
                            path.Visibility = Visibility.Hidden;
                        }
                    }
                }
            }
        }
    }