I am selecting my tests from the database table, I want to create a textbox in front of every test, where the user will enter a result for each test, and be able to save results for each test . The error message i get is
"index was outsite the bounds of the array"
int tindex=0;
TextBox[] rst = new TextBox[tindex];
try
{
while (sub.Read())
{
tindex++;
Label tst = new Label();
tst.Location = new Point(1, startingpoint);
tst.Name = "textBoxf";
tst.Size = new Size(200, 18);
tst.BorderStyle = BorderStyle.None;
tst.BackColor = SystemColors.Control;
tst.Text += sub.GetString("abbrev");
try
{
rst[tindex] = new TextBox();
rst[tindex].Location = new Point(120, startingpoint);
rst[tindex].Name = "textBoxf";
rst[tindex].Size = new Size(70, 12);
rst[tindex].BorderStyle = BorderStyle.None;
rst[tindex].BackColor = SystemColors.Control;
rst[tindex].TabIndex = tindex;
rst[tindex].TextChanged += rst_textchanged;
rst[tindex].KeyDown += rst_KeyDown;
TextBox rsts = rst[tindex];
panel7.Controls.Add(rst[tindex]);
}
catch(Exception er)
{
MessageBox.Show(er.Message);
}
}
int tindex=0; TextBox[] rst = new TextBox[tindex];...have a look at this code. How big is the array it creates?