作成日: 2015/03/10 最終更新日: 2015/03/10
文書種別
使用方法
詳細
行の境界線ダブルクリック時に選択中のすべての行をリサイズするには、既定の処理でクリック対象行がリサイズされるRowResizedイベントで他の選択中の行もリサイズします。
◎サンプルコード(Visual Basic)
◎サンプルコード(C#)
◎サンプルコード(Visual Basic)
Public Sub New()
InitializeComponent()
' データ設定
Me.c1DataGrid1.ItemsSource = New StockCollection()
' イベント設定
AddHandler c1DataGrid1.RowResized, AddressOf c1DataGrid1_RowResized
End Sub
Private Sub c1DataGrid1_RowResized(sender As Object, e As C1.WPF.DataGrid.DataGridRowEventArgs)
Dispatcher.BeginInvoke(New Action(Sub()
Dim rowHeight As Double = e.Row.ActualHeight
' 選択中の行をリサイズ
For Each drow As C1.WPF.DataGrid.DataGridRow In c1DataGrid1.Selection.SelectedRows
drow.Height = New C1.WPF.DataGrid.DataGridLength(rowHeight)
Next
End Sub),
System.Windows.Threading.DispatcherPriority.Render)
End Sub
InitializeComponent()
' データ設定
Me.c1DataGrid1.ItemsSource = New StockCollection()
' イベント設定
AddHandler c1DataGrid1.RowResized, AddressOf c1DataGrid1_RowResized
End Sub
Private Sub c1DataGrid1_RowResized(sender As Object, e As C1.WPF.DataGrid.DataGridRowEventArgs)
Dispatcher.BeginInvoke(New Action(Sub()
Dim rowHeight As Double = e.Row.ActualHeight
' 選択中の行をリサイズ
For Each drow As C1.WPF.DataGrid.DataGridRow In c1DataGrid1.Selection.SelectedRows
drow.Height = New C1.WPF.DataGrid.DataGridLength(rowHeight)
Next
End Sub),
System.Windows.Threading.DispatcherPriority.Render)
End Sub
◎サンプルコード(C#)
public KB81211()
{
InitializeComponent();
// テストデータ設定
this.c1DataGrid1.ItemsSource = new StockCollection();
// イベント設定
c1DataGrid1.RowResized += c1DataGrid1_RowResized;
}
void c1DataGrid1_RowResized(object sender, C1.WPF.DataGrid.DataGridRowEventArgs e)
{
if (c1DataGrid1.Selection.SelectedRows.Contains(e.Row))
{
Dispatcher.BeginInvoke(new Action(() => {
double rowHeight = e.Row.ActualHeight;
// 選択中の行をリサイズ
foreach (C1.WPF.DataGrid.DataGridRow drow in c1DataGrid1.Selection.SelectedRows)
{
drow.Height = new C1.WPF.DataGrid.DataGridLength(rowHeight);
}
}), System.Windows.Threading.DispatcherPriority.Render);
}
}
{
InitializeComponent();
// テストデータ設定
this.c1DataGrid1.ItemsSource = new StockCollection();
// イベント設定
c1DataGrid1.RowResized += c1DataGrid1_RowResized;
}
void c1DataGrid1_RowResized(object sender, C1.WPF.DataGrid.DataGridRowEventArgs e)
{
if (c1DataGrid1.Selection.SelectedRows.Contains(e.Row))
{
Dispatcher.BeginInvoke(new Action(() => {
double rowHeight = e.Row.ActualHeight;
// 選択中の行をリサイズ
foreach (C1.WPF.DataGrid.DataGridRow drow in c1DataGrid1.Selection.SelectedRows)
{
drow.Height = new C1.WPF.DataGrid.DataGridLength(rowHeight);
}
}), System.Windows.Threading.DispatcherPriority.Render);
}
}
旧文書番号
81211