作成日: 2026/06/24 最終更新日: 2026/06/24
文書種別
使用方法
詳細
列のドラッグ移動時に表示されるインジケータのスタイルを変更するには、ドラッグインジケーター(GrapeCity.Windows.SpreadGrid.Presenters.DragIndicatorクラス)のスタイルをオーバーライドします。
◎サンプルコード(VB)
◎サンプルコード(VB)
Imports GrapeCity.Windows.SpreadGrid.Presenters
Private Sub Window_Loaded(sender As Object, e As RoutedEventArgs)
gcSpreadGrid1.ColumnDragMode = GrapeCity.Windows.SpreadGrid.DragMode.Direct
EventManager.RegisterClassHandler(GetType(DragIndicator), Control.LoadedEvent, New RoutedEventHandler(AddressOf Me.DragIndicator_Loaded))
End Sub
Private Sub DragIndicator_Loaded(sender As Object, e As RoutedEventArgs)
Dim ctl As DragIndicator = CType(sender, DragIndicator)
Dim activeCellPosition As GrapeCity.Windows.SpreadGrid.CellPosition = gcSpreadGrid1.ActiveCellPosition
If activeCellPosition.IsEmpty Then
Return
End If
Dim customContent As Border = New Border
Dim textBlock As TextBlock = New TextBlock
textBlock.Text = activeCellPosition.ColumnName
textBlock.Background = Brushes.Yellow
textBlock.Padding = New Thickness(16, 4, 16, 4)
textBlock.FontWeight = FontWeights.Bold
customContent.Child = textBlock
ctl.Content = customContent
ctl.Style = CType(Application.Current.Resources("DragIndicatorBorderless"), Style)
End Sub
◎サンプルコード(C#)using GrapeCity.Windows.SpreadGrid.Presenters;
private void Window_Loaded(object sender, RoutedEventArgs e)
{
gcSpreadGrid1.ColumnDragMode = GrapeCity.Windows.SpreadGrid.DragMode.Direct;
EventManager.RegisterClassHandler(typeof(DragIndicator), Control.LoadedEvent, new RoutedEventHandler(DragIndicator_Loaded));
}
private void DragIndicator_Loaded(object sender, RoutedEventArgs e)
{
var ctl = (DragIndicator)sender;
var activeCellPosition = gcSpreadGrid1.ActiveCellPosition;
if (activeCellPosition.IsEmpty)
{
return;
}
var customContent = new Border
{
Child = new TextBlock
{
Text = activeCellPosition.ColumnName,
Background = Brushes.Yellow,
Padding = new Thickness(16, 4, 16, 4),
FontWeight = FontWeights.Bold
},
BorderThickness = new Thickness(2),
BorderBrush = Brushes.Red
};
ctl.Content = customContent;
ctl.Style = (Style)Application.Current.Resources["DragIndicatorBorderless"];
}