UltraWinGrid - 按行获取组的当前单元格/列

发布于 2024-11-07 06:23:52 字数 1301 浏览 0 评论 0原文

如果活动单元格的类型为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暖伴 2024-11-14 06:23:52

如果 GetContext 中的列为 null,则对 UltraGridGroupByRow 类型再次进行 GetContext 调用。如果返回一个实例,请从中获取 Column 属性,这将为您提供该行引用的分组列。

If the column from the GetContext is null, make another GetContext call for the type UltraGridGroupByRow. If an instance is returned, get the Column property from it and that will give you the grouped column to which that row refers.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文