Rov*_*ver 1 .net c# wpf telerik radgridview
我想有能力选择单元格和选择行。为了选择单元格,我设置了 SelectionUnit="Cells" 和 SelectionMode="Extended"。它工作正常。但现在我需要能够选择行。用户可以通过行标题(在行的左侧)选择行。
如何轻松实现?
快速解决:
private void RadGridView_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
if(e.RightButton == MouseButtonState.Pressed)
return;
var source = e.OriginalSource as DependencyObject;
if(source == null)
return;
var cell = source.FindVisualParent<GridViewCell>();
if(cell != null)
{
((RadGridView)sender).SelectionUnit = GridViewSelectionUnit.Cell;
}
else
{
var row = source.FindVisualParent<GridViewRow>();
if(row != null)
{
((RadGridView)sender).SelectionUnit = GridViewSelectionUnit.FullRow;
}
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1706 次 |
最近记录: |