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
There's no need to write a recursive routine to loop through all of the rows in the grid at every level. We've done that for you. I posted the code above, but here is it again:
foreach (UltraGridRow row in this.ultraGrid1.Rows.GetFilteredInNonGroupByRows()) { }
This code will loop through ALL of the rows in the grid regardless of what band or group they are in.
If you want a specific row, like in your question 2 example, then you don't have enough information here. You say the 3rd childband, but there's no single list of rows in the third child band. You would have to know which row in the first band and then child child row in the second band you wanted. But assuming you want the first row of band 0 and the first row of band 1 under that, the code would look something like this:
UltraGridRow band0Row = this.ultraGrid1.Rows[0]; UltraGridRow band1Row = band0Row.ChildBands[0].Rows[0]; UltraGridRow band2Row = band1Row.ChildBands[0].Rows[2]; Debug.WriteLine(band2Row.Cells["Column Key"].Value.ToString());