i have a usercontrol which is added to my main form via a click button event.
Each time the button is clicked a newbox is added and a counter called "nextbox" is incremented. Does any one know how to get the text from the textboxes within the usercontrol? It seems like it should be easier than it is. The two textboxes within the usercontrol have their modifiers set to public.
private void button2_Click(object sender, EventArgs e)
newBox box = new newBox();
if (newBox1.textBox1.Text == "0")
MessageBox.Show("Please Enter Length!");
draw = true;
box.Location = new System.Drawing.Point(panel1.AutoScrollPosition.X + boxXcoord, panel1.AutoScrollPosition.Y + boxYcoord);
box.TabIndex = nextBox;
boxYcoord += newboxcoord;
box.Name = nextBox.ToString();
length = box.textBox1.Text;
angle = box.TextBox2.Text;
lineClass.sideLengthA = double.Parse(length);
lineClass.angleInDegs = double.Parse(angle);
lineClass.angleInRads = (Math.PI*(lineClass.angleInDegs+90)/180);
MessageBox.Show("Length = " + length.ToString());
MessageBox.Show("Angle = " + angle.ToString());
Xdestin = (Convert.ToInt32(sideA * Math.Sin(lineClass.angleInRads)) + Xorigin);
Ydestin = (Convert.ToInt32(sideA * Math.Cos(lineClass.angleInRads)) + Yorigin);
Create property of those textbox and expose those property.
Make your textbox in the usercontrol public, then you will be able to access it.
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)