开发者

UltraWinGrid - Get Current Cell/Column for a group by row

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;
    v开发者_运维知识库ar 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜