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
260
searching a text from expandable childband grid
posted

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