UltraWinGrid - 按行获取组的当前单元格/列
如果活动单元格的类型为 double 或 int,我试图为所选行提供快速摘要。如果网格未按任何列分组,则此方法可以正常工作。但是,当网格按一列或多列分组时,选择顶级行时没有活动单元格。
void ultraGrid_AfterSelectChange(object sender, AfterSelectChangeEventArgs e)
{
var ultraGrid = ((UltraGrid)sender);
var selected = ultraGrid.Selected;
var hasCells = selected.Cells != null && selected.Cells.Count > 0;
var hasRows = selected.Rows != null && selected.Rows.Count > 0;
if ( !hasCells && !hasRows )
{
statusLabel.Text = string.Empty;
return;
}
UltraGridColumn activeColumn;
var activeCell = ultraGrid.ActiveCell;
if( activeCell == null )
{
var aUIElement = ultraGrid.DisplayLayout.UIElement.ElementFromPoint( ultraGrid.PointToClient(MousePosition));
activeColumn = (UltraGridColumn)aUIElement.GetContext(typeof(UltraGridColumn));
}
else activeColumn = activeCell.Column;
if( activeColumn == null || (activeColumn.DataType != typeof (double) && activeColumn.DataType != typeof (int) ) )
{
statusLabel.Text = string.Empty;
return;
}
//code to calculate summaries for selected rows or cells and active column
}
但当选择按行分组时,aUIElement.GetContext(typeof(UltraGridColumn)) 始终返回 null。 选择按行分组时如何获得活动列/单元格?
I am trying to provide quick summary for the selected rows if the active cell is of type double or int. This works fine if the grid is not grouped by any column. But when grid is grouped by one or more columns, there is no active cell when top level rows are selected.
void ultraGrid_AfterSelectChange(object sender, AfterSelectChangeEventArgs e)
{
var ultraGrid = ((UltraGrid)sender);
var selected = ultraGrid.Selected;
var hasCells = selected.Cells != null && selected.Cells.Count > 0;
var hasRows = selected.Rows != null && selected.Rows.Count > 0;
if ( !hasCells && !hasRows )
{
statusLabel.Text = string.Empty;
return;
}
UltraGridColumn activeColumn;
var activeCell = ultraGrid.ActiveCell;
if( activeCell == null )
{
var aUIElement = ultraGrid.DisplayLayout.UIElement.ElementFromPoint( ultraGrid.PointToClient(MousePosition));
activeColumn = (UltraGridColumn)aUIElement.GetContext(typeof(UltraGridColumn));
}
else activeColumn = activeCell.Column;
if( activeColumn == null || (activeColumn.DataType != typeof (double) && activeColumn.DataType != typeof (int) ) )
{
statusLabel.Text = string.Empty;
return;
}
//code to calculate summaries for selected rows or cells and active column
}
But aUIElement.GetContext(typeof(UltraGridColumn)) always return null when group by rows are selected.
How do I get active column / cell when group by rows are selected?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果
GetContext
中的列为 null,则对UltraGridGroupByRow
类型再次进行GetContext
调用。如果返回一个实例,请从中获取 Column 属性,这将为您提供该行引用的分组列。If the column from the
GetContext
is null, make anotherGetContext
call for the typeUltraGridGroupByRow
. If an instance is returned, get theColumn
property from it and that will give you the grouped column to which that row refers.