I have one grid that has two bands.
How to determine which band is being selected or band row being selected
Basically, I want to write some logic that saids
If( Band[1] Is active or any row is selected)
{"do nothing, at the moment I careless about band[1], it there for visual at the moment."}
else if (Band[0] is selected or row is selected)
{"get data"}
No, that is not correct.
ultraGrid1.Rows is the root-level rows collection of the grid. If you specify ultraGrid1.Rows[0] or use any number inside the brackets, you will always get a row in Band 0.
The code Michael posted above is using the Selected property on the grid to get the Selected rows, not the root rows.
ultraGrid1.Selected.Rows[0]
I suspect you don't care about selection, you are probably more concerned with the active row.
ultraGrid1.ActiveRow
Whatever row you are working with doesn't really matter. Once you get whatever row you care about, the row has a Band property on it, so you can then examine the Key or Index of the band to determine which band that row belongs to.
Almost, this works for me:
if (UltraGrid1.Selected.Rows.Count > 0){ if (UltraGrid1.Selected.Rows[0].Band.Index == 0) { //do something } else { //do nothing }}
It doesn't matter which row the band[1] row belongs to.
So are you telling me if 5 rows of Band[0] and each band has relative Band[1]
if I click on any of the 5 Band[1] rows it would jump in the else statement below?
if
(ultraGrid1.Rows[0].Band.Index == 0)
{
do something
}
else
do nothing
Hey,
With the UltraGrid.Selected you can retrieve what is selected.
Example:retrieve the band index of the first selected row: UltraGrid.Selected.Rows(0).Band.Index retrieve the band index of the first selected cell: UltraGrid.Selected.Cells(0).Band.Index
If no cell, row or column is selected, I'm not sure if any band is selected and as such I don't think you'll be able to retrieve that.
Kind regards,
Michael