C
Carlo Goretti
Guest
Hey!
Im trying to make that if you check a dynamic checkbox. then a dynamic Button appears. If you uncheck it. then it removes.
Have got it to work on one but can get it to work on everyone..
Look here:
Here is my code for this:
for (int i = 0; i < files.Count(); i++)
{
box = new CheckBox();
btn = new Button();
box.Tag = i;
box.Font = new Font(box.Font.FontFamily, 8);
box.ForeColor = Color.White;
box.AutoSize = true;
box.Text = Path.GetFileName(files);
box.Location = new Point(0, (i * 25));
box.CheckedChanged += new EventHandler(Checkbox_Click);
lstChckBox.Add(box);
GåVidareBtn.Visible = false;
Height = KörBtn.Location.Y + KörBtn.Height + 60;
KörBtn.Visible = true;
panel1.Controls.Add(box);
}
void Checkbox_Click(object sender, EventArgs e)
{
for (int i = 0; i < lstChckBox.Count(); i++)
{
if (lstChckBox.Checked == true)
{
btn.Size = new Size(75, 20);
btn.Location = new Point(lstChckBox[0].Location.X + lstChckBox[0].Width + 125, lstChckBox.Location.Y);
btn.FlatStyle = FlatStyle.Flat;
btn.FlatAppearance.BorderSize = 0;
btn.BackColor = Color.FromArgb(254, 66, 2);
btn.ForeColor = Color.White;
btn.Font = new Font(btn.Font.FontFamily, 8);
btn.Text = "Öppna";
btn.Click += new EventHandler(btn_Click);
panel1.Controls.Add(btn);
break;
}
else if (lstChckBox.Checked == false)
{
panel1.Controls.Remove(btn);
}
}
}
Very thankful for some help out..
Cant get it to work..
Best regards!
Continue reading...
Im trying to make that if you check a dynamic checkbox. then a dynamic Button appears. If you uncheck it. then it removes.
Have got it to work on one but can get it to work on everyone..
Look here:
Here is my code for this:
for (int i = 0; i < files.Count(); i++)
{
box = new CheckBox();
btn = new Button();
box.Tag = i;
box.Font = new Font(box.Font.FontFamily, 8);
box.ForeColor = Color.White;
box.AutoSize = true;
box.Text = Path.GetFileName(files);
box.Location = new Point(0, (i * 25));
box.CheckedChanged += new EventHandler(Checkbox_Click);
lstChckBox.Add(box);
GåVidareBtn.Visible = false;
Height = KörBtn.Location.Y + KörBtn.Height + 60;
KörBtn.Visible = true;
panel1.Controls.Add(box);
}
void Checkbox_Click(object sender, EventArgs e)
{
for (int i = 0; i < lstChckBox.Count(); i++)
{
if (lstChckBox.Checked == true)
{
btn.Size = new Size(75, 20);
btn.Location = new Point(lstChckBox[0].Location.X + lstChckBox[0].Width + 125, lstChckBox.Location.Y);
btn.FlatStyle = FlatStyle.Flat;
btn.FlatAppearance.BorderSize = 0;
btn.BackColor = Color.FromArgb(254, 66, 2);
btn.ForeColor = Color.White;
btn.Font = new Font(btn.Font.FontFamily, 8);
btn.Text = "Öppna";
btn.Click += new EventHandler(btn_Click);
panel1.Controls.Add(btn);
break;
}
else if (lstChckBox.Checked == false)
{
panel1.Controls.Remove(btn);
}
}
}
Very thankful for some help out..
Cant get it to work..
Best regards!
Continue reading...