hi, here i developed code for searching a text from grid row -> childband row
Infragistics.Win.UltraWinGrid.UltraGrid InfraGrid = (Infragistics.Win.UltraWinGrid.UltraGrid)SourceControl; UltraGridRow ChildSelectionRow = null; int test =0; int MainRowIndex, ChildRowIndex; ChildSelectionRow = InfraGrid.Rows[test]; ArrayList ListChk = new ArrayList(); MainRowIndex = Convert.ToInt32(startSearchRow.Split('~')[0]); ChildRowIndex = Convert.ToInt32(startSearchRow.Split('~')[1]); int childcolumn = Convert.ToInt32(columnIndex); int selRowIndex = -1; MainRowIndex--; ChildRowIndex--; childcolumn--; //Getting the list of rows index in an array string[] words = startSearchRow.Split('~'); -> spliting the value like (row)0,childbandrow(0),text foreach (string word in words) { int i = 0; string s = word; if (!int.TryParse(s, out i)) //i now = 108 { MessageBox.Show("Values are modified as string"); return "NULL"; } else { //MessageBox.Show("entered else part"); ListChk.Add(word); } } //Expand the row based on its index for (int i = 0; i < ListChk.Count; i++) { int.TryParse(ListChk[i].ToString(), out test); if (i == 0) { ChildSelectionRow = InfraGrid.Rows[test]; } else { if (i <= ListChk.Count - 1) { if (MainRowIndex >= 0 && ChildRowIndex >= 0 && childcolumn >= 0) { if (InfraGrid.Rows[MainRowIndex].IsExpandable) { InfraGrid.Rows[MainRowIndex].Expanded = true; InfraGrid.Rows[MainRowIndex].Selected = true; if (InfraGrid.Rows[MainRowIndex].ChildBands.Count > 0) { if (InfraGrid.Rows[MainRowIndex].ChildBands[0].Rows.Count > 0 && InfraGrid.Rows[MainRowIndex].ChildBands[0].Rows.Count > ChildRowIndex) { if (InfraGrid.Rows[MainRowIndex].ChildBands[0].Rows[ChildRowIndex].Cells.Count > childcolumn) { if (InfraGrid.Rows[MainRowIndex].ChildBands[0].Rows[ChildRowIndex].Cells[childcolumn].Text == text) { selRowIndex = ChildRowIndex + 1; } else { for (int ii = ChildRowIndex; ii < InfraGrid.Rows[MainRowIndex].ChildBands[0].Rows.Count; ii++) { if (InfraGrid.Rows[MainRowIndex].ChildBands[0].Rows[ii].Cells[childcolumn].Text == text) { selRowIndex = ii + 1; break; } } } } } } } } } } } return "RowIndex :" + selRowIndex;
My Doubt is:
1. i need to iterate childband within childband and need to search the text from childband row.
Thanks
Srinivasan J
Hi Srinivasan,
If I understand you correct, what you want to do is search the root-level row (InfraGrid.Rows[MainRowIndex]) and all of it's descendants in all child bands? Is that right?
If that's what you want, then you are almost there. Your code is currently limited to only the first child band and it's not walking down the chain recursively. So first you have to make sure you include all child bands. And second, you have to walk down the descendants recursively, in case those child bands have child bands of their own.
The first part can be achieved by looping through the ChildBands collection of the row. So instead of just accessing ChildBands[0], you need to loop like this:
foreach (UltraGridChildBand childBand in row.ChildBands) { }
Inside this loop, you can walk down the chain recursively by making use of the enumerators provided by the rows collection. There are methods on the rows collection that give you recursive enumerators for convenience.
UltraGridRow row = this.ultraGrid1.Rows[0]; foreach (UltraGridChildBand childBand in row.ChildBands) { //foreach (UltraGridRow descendantRow in childBand.Rows.GetFilteredInNonGroupByRows) foreach (UltraGridRow descendantRow in childBand.Rows.GetAllNonGroupByRows()) { } }
I put two options inside the loop here, because right now your code does not account for filtering. So your results could end up with an invisible row. So if you want to ignore hidden rows, use GetFilteredInNonGroupByRows instead of GetAllNonGroupByRows.
Using this methods should simplify your code quite a bit.
Also, if you don't want to limit the search to a single root-level row, you could easily loop through every row in the grid like this:
foreach (UltraGridRow row in this.ultraGrid1.Rows.GetFilteredInNonGroupByRows()) { }
Hi Mike Saltzman
I am new to Infragistics technology, I am learning the things day by day, can you elaborate the code for above you explained me. If you explain me with some set of code, it will be more good for my understading.
srinivasan J