int n = 25;
int m = 1;
private void form1_MouseClick(object sender, MouseEventArgs e)
{
TextBox txtBox = new TextBox();
txtBox.Text = "TextBox" + m;
txtBox.TabIndex = m;
txtBox.Tag = m;
txtBox.Location = new System.Drawing.Point(10, n);
txtBox.Size = new System.Drawing.Size(70, 20);
txtBox.Name = "TextBox" + m;
name = txtBox.Name;
txtBox.Click += new EventHandler(txtBox_Click);
this.Controls.Add(txtBox);
TreeNode root = null;
if (TV.Nodes.Count == 0) //Treeview Name
{
root = new TreeNode("TextBox");
root.Nodes.Add(txtBox.Name);
TV.Nodes.Add(root);
}
else
{
TV.Nodes[0].Nodes.Add(txtBox.Name);
}
TV.ExpandAll();
n = n + 20;
m++;
}
private void LnkRemoveCtrl_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
int index = m - 1;
if (index > 0)
{
Control c = this.Controls["TextBox" + index.ToString()];
this.Controls.Remove(c);
TV.Nodes[0].LastNode.Remove();
n = n - 20;
m--;
}
}
Friday, July 20, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment