Hi
I managed to dynamically form textboxes using c#. I want include another button, whenever i enter any values in those textboxes i should get sum in message box. i donno how to use code for dynamic texboxes. This is what i have done,
[code=c#]
namespace WindowsFormsApp lication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeCompo nent();
}
private void button1_Click(o bject sender, EventArgs e)
{
int y=50;
int j = int.Parse(textB ox1.Text);
TextBox[] txt = new TextBox[j];
if (j < 20)
{
for (int i = 0; i < j; i++)
{
txt[i] = new TextBox();
txt[i].AutoSize = true;
txt[i].Location = new Point(150, y);
this.Controls.A dd(txt[i]);
y = y + 30;
}
}
else
{
MessageBox.Show (" enter values below 20");
}
}
private void button2_Click(o bject sender, EventArgs e)
{
}
private void Form1_Load(obje ct sender, EventArgs e)
{
}
}
}
[/code]
What code should i use to add the values in the textbox
I managed to dynamically form textboxes using c#. I want include another button, whenever i enter any values in those textboxes i should get sum in message box. i donno how to use code for dynamic texboxes. This is what i have done,
[code=c#]
namespace WindowsFormsApp lication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeCompo nent();
}
private void button1_Click(o bject sender, EventArgs e)
{
int y=50;
int j = int.Parse(textB ox1.Text);
TextBox[] txt = new TextBox[j];
if (j < 20)
{
for (int i = 0; i < j; i++)
{
txt[i] = new TextBox();
txt[i].AutoSize = true;
txt[i].Location = new Point(150, y);
this.Controls.A dd(txt[i]);
y = y + 30;
}
}
else
{
MessageBox.Show (" enter values below 20");
}
}
private void button2_Click(o bject sender, EventArgs e)
{
}
private void Form1_Load(obje ct sender, EventArgs e)
{
}
}
}
[/code]
What code should i use to add the values in the textbox
Comment