Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
985
Get info from selected band
posted

I have an UltraWinGrid that is bound to a datasource. I set the grid to group the contents by a key value. I want my users to be able to add an extra row to the group they have currently selected.

This is no problem when they have a row selected as I am able to use the ActiveRow property then to determine the keyvalue that I need. The problem I am having is that the user can also select the headers of the groups and thus have no ActiveRow. I need to be able to read the keyvalue of the group that the user has selected to be able to add a new row to my collection, so that it can be placed in the correct group afterwards.

Is there a way to determine which group/band the user has selected if they have no actual row selected in the grid, but only the header?

Parents
No Data
Reply
  • 69832
    Offline posted

    SelectedColsCollection selectedCols = this.ultraGrid.Selected.Columns;
    UltraGridColumn col = selectedCols.Count > 0 ? selectedCols[0].Column : null;
    UltraGridGroup group = col != null ? col.Group : null;
    if ( group != null && group.Header.Selected )
    {
        UltraGridBand band = group.Band;
    }

    I can't remember if the grid allows columns from different bands to be selected concurrently (I don't think it does) ; if it does, you would have to do something like handle AfterSelectChange and execute this code in response to that event, then cache the UltraGridBand reference so that you always have the most recently selected one.

Children