pai_prasad
asked on
Two dimensional array of textboxes
Hi,
I want to have a 2dimensional array of textboxes ...
I wrote this code..( learning C# so pls be patient)
for (int x = 0; x<8; x++)
for (int i = 0; i<8; i++)
{
System.Windows.Forms.TextB ox[][]tb ;
-----------------> tb[x][i]= new System.Windows.Forms.TextB ox();
tb[x][i].Text = "";
tb[x][i].TabIndex = i;
tb[x][i].Size = new System.Drawing.Size(20,20) ;
tb[x][i].Location = new System.Drawing.Point(x*70, i*25);
tb[x][i].Text = i.ToString();
this.Controls.Add(tb[x][i] );
}
ERROR: Use of unassigned local variable 'tb'
How do i solve this
I want to have a 2dimensional array of textboxes ...
I wrote this code..( learning C# so pls be patient)
for (int x = 0; x<8; x++)
for (int i = 0; i<8; i++)
{
System.Windows.Forms.TextB
-----------------> tb[x][i]= new System.Windows.Forms.TextB
tb[x][i].Text = "";
tb[x][i].TabIndex = i;
tb[x][i].Size = new System.Drawing.Size(20,20)
tb[x][i].Location = new System.Drawing.Point(x*70,
tb[x][i].Text = i.ToString();
this.Controls.Add(tb[x][i]
}
ERROR: Use of unassigned local variable 'tb'
How do i solve this
Alternatives as well,
//Framework 1.1
ArrayList list = new ArrayList();
list.Add(new System.Windows.Forms.TextB
//Framework 2.0
System.Collections.Generic
list.Add(new System.Windows.Forms.TextB
I would still learn to use arrays though. They are a critical element in comptuer science.
ASKER
i tried that ...
System.Windows.Forms.TextB ox[][]tb = new TextBox[8][];
it gives error: Object reference not set to an instance of an object. on
tb[x][i].Text = "";
System.Windows.Forms.TextB
it gives error: Object reference not set to an instance of an object. on
tb[x][i].Text = "";
see your not using a 2 dimensional array, your using an array of an array
int size = 50;
System.Windows.Forms.TextB
int size2 = 2;
tb[0] = new System.Windows.Forms.TextB
2d array looks like System.Windows.Forms.TextB
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks for the answer,,
but how do i add a text_changed event listener and retrieve the value
any links for that?
but how do i add a text_changed event listener and retrieve the value
any links for that?
are you kidding me, he took my answer and pasted it in code. wonderful.
need to make,
int size = 50;
System.Windows.Forms.TextB