没有直接的方法来查找是否在AfterRowActivate事件中单击了布尔单元格。例如,点击行选择器后,该事件可能会触发并激活该行。你可以尝试的是获得用户点击的UIElement。如果UIElement是CheckEditorCheckBoxUIElement,最有可能显示复选框单元格被点击。
private void UltraGrid1_AfterRowActivate(object sender, EventArgs e)
{
var grid = sender as UltraGrid;
if(grid == null)
return;
// Get the element where user clicked
var element = grid.DisplayLayout.UIElement.ElementFromPoint(grid.PointToClient(Cursor.Position));
// Check if the element is CheckIndicatorUIElement. If so the user clicked exactly
// on the check box. The element's parent should be CheckEditorCheckBoxUIElement
CheckEditorCheckBoxUIElement checkEditorCheckBoxElement = null;
if(element is CheckIndicatorUIElement)
{
checkEditorCheckBoxElement = element.Parent as CheckEditorCheckBoxUIElement;
}
// Check if the element is CheckEditorCheckBoxUIElement. If so the user clicked
// on a check box cell, but not on the check box
else if(element is CheckEditorCheckBoxUIElement)
{
checkEditorCheckBoxElement = element as CheckEditorCheckBoxUIElement;
}
// If checkEditorCheckBoxElement is not null check box cell was clicked
if(checkEditorCheckBoxElement != null)
{
// You can get the cell from the parent of the parent of CheckEditorCheckBoxUIElement
// Here is the hierarchy:
// CellUIElement
// EmbeddableCheckUIElement
// CheckEditorCheckBoxUIElement
// CheckIndicatorUIElement
// Find the CellUIElement and get the Cell of it
if(checkEditorCheckBoxElement.Parent != null && checkEditorCheckBoxElement.Parent.Parent != null)
{
var cellElement = checkEditorCheckBoxElement.Parent.Parent as CellUIElement;
if(cellElement != null)
{
var cell = cellElement.Cell;
}
}
}
}
有一个AfterCellActivate在CellChanged事件之前引发,包含有关单击单元格的信息。 AfterRowActivate接收到正常的EventArgs参数,但没有任何关于当前单元格的信息。为什么你需要处理AfterRowActivate? – Steve
问题是,我在UltraDockManager中有一个UltraPanel,并且想要显示或隐藏面板,具体取决于活动行是否检查了布尔列。所以我需要AfterRowActivate来显示或隐藏面板,但同样需要CellChange。 AfterCellActivate在CellChange之前但在AfterRowActivate之后引发之后,因此在处理AfterRowActivate的方法中,我不知道布尔单元格的值是否会因为只有动作而被改变(单击布尔列的单元格,活跃的行)。任何想法都会非常有帮助。 @Steve – Robin