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?
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.
This code does not seem to work. When the only the header is selected all the items in the ultraGrid.Selected are empty (cells, columns and rows).
To clarify: by header I mean the line above the column headers that gets created when items are groups. Per default it contains the name of the property that is being grouped by, the value of the property and the amount of items in the group. For example: UserID: 12 (4 items).
When that header is clicked I need to know the value of UserID of that group. Reading it from the caption won't be an option as I will modify that to say something different in my final version of my program.