J
John
Hi all:
I am writing an app that parses a data file with rows of data, and each row
has an unknown number of data values separated by commas. What I need to do
is set up a column of text boxes and implement a MouseDOwn event in each of
the text boxes that replaces the text box by a drop-down when the mouse is
clicked in the text box. However, since I am dynamically declaring and
positioning the text boxes, how can I attach event handlers?
For example, if we declare a TB and event handler we get this:
this.textBox1.MouseDown += new
System.Windows.Forms.MouseEventHandler(this.textBox1_MouseDown_1);
private void textBox1_MouseDown_1(object sender,
System.Windows.Forms.MouseEventArgs e)
{
}
But I am setting up my text boxes like this:
System.Windows.Forms.TextBox[] boxes = new System.Windows.Forms.TextBox[
delimiterCount ];
for ( int i=0; i<delimiterCount; i++)
{
boxes[ i ] = new System.Windows.Forms.TextBox();
boxes.Location = new System.Drawing.Point(0, yPoint );
boxes.Size = new System.Drawing.Size(100,25);
boxes.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.Controls.Add(boxes);
}
and I cannot add
boxes.MouseDown += new
System.Windows.Forms.MouseEventHandler(boxes._MouseDown_1);
to the loop...
Anyone have any ideas?
Thanks.
John.
I am writing an app that parses a data file with rows of data, and each row
has an unknown number of data values separated by commas. What I need to do
is set up a column of text boxes and implement a MouseDOwn event in each of
the text boxes that replaces the text box by a drop-down when the mouse is
clicked in the text box. However, since I am dynamically declaring and
positioning the text boxes, how can I attach event handlers?
For example, if we declare a TB and event handler we get this:
this.textBox1.MouseDown += new
System.Windows.Forms.MouseEventHandler(this.textBox1_MouseDown_1);
private void textBox1_MouseDown_1(object sender,
System.Windows.Forms.MouseEventArgs e)
{
}
But I am setting up my text boxes like this:
System.Windows.Forms.TextBox[] boxes = new System.Windows.Forms.TextBox[
delimiterCount ];
for ( int i=0; i<delimiterCount; i++)
{
boxes[ i ] = new System.Windows.Forms.TextBox();
boxes.Location = new System.Drawing.Point(0, yPoint );
boxes.Size = new System.Drawing.Size(100,25);
boxes.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.Controls.Add(boxes);
}
and I cannot add
boxes.MouseDown += new
System.Windows.Forms.MouseEventHandler(boxes._MouseDown_1);
to the loop...
Anyone have any ideas?
Thanks.
John.