gpt4 book ai didi

c# - 鼠标右键选择单元格

转载 作者:太空宇宙 更新时间:2023-11-03 13:56:14 25 4
gpt4 key购买 nike

如何通过鼠标右键选择RadGridView中的单元格?

以下代码无效:

private void RadGridView_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
// ... getting grid and cell
if (e.RightButton == MouseButtonState.Pressed)
{
grid.UnselectAll();
grid.CurrentCellInfo = new GridViewCellInfo(cell);
cell.IsCurrent = true;
cell.IsSelected = true;
}
}

很奇怪,但是选择行可以正常工作:

if (e.RightButton == MouseButtonState.Pressed)
{
grid.UnselectAll();
row.IsSelected = true;
row.IsCurrent = true;
}

最佳答案

if (e.RightButton == MouseButtonState.Pressed)
{
grid.Focus();
grid.UnselectAll();
grid.CurrentCellInfo = new GridViewCellInfo(cell);
grid.SelectedCells.Add(grid.CurrentCellInfo);
}

关于c# - 鼠标右键选择单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12092030/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com