Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am trying to do something similar to query designer in ms access
so when i click on tablename it should add respective listbox in tabpage
and the list box should get populated with different valus ihave tried n code but its not working
C#
if (tabControl2.SelectedTab == TABQUERYDESIGNER)
           {

               ListBox[] lstbxQueryDesigner = new ListBox[100];

               TABQUERYDESIGNER.Controls.Add(lstbxQueryDesigner[lstbxno]);
               _objDEFfile.ReadDeftoLIst((@"C:\Datagenerator\" + Connection.Username + @"\" + Connection.Requirementname + @"\Configuration\" + listbxDef.SelectedItem.ToString() + ".def"));
               foreach (string r in DEFfile.listDef)
               {
                   r.Replace("  ", " ");//sd
                   r.Replace("| ", "|");//sd
                   r.Replace(" |", "|");//sd
                   //Split the row at the delimiter.
                   columnreader = r.Split("|".ToCharArray());
                   rowreader = columnreader[0].Split(" ".ToCharArray());
                   if (rowreader[0] == "F")
                   {
                       lstbxQueryDesigner[lstbxno].Items.Add(rowreader[1].ToUpper());

                   }
               }

           }
           lstbxno += 1;
       }
Posted
Comments
Rey Terativo 19-Oct-12 6:03am    
A few things:
1) Your ListBox array is declared inside a block, it should be a class variable.
2) Strings are immutable, so methods that modify strings return the modified string.
r = r.Replace("| ","|");
3) You don't need to convert the Split parameter into an array of characters. Examples:
columnreader = r.Split('|');
tokens = textline.Split(' ', '-', ';');

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900