1-) C# - dinamik nesne oluşturmak(radio button)
malzemeler= 1 panel 1 button
1-)System.InvalidOperationException hatası alırsan
http://www.yazilimcirehberi.com/tag/system-invalidoperationexception/
private void Form1_Load(object sender, EventArgs e)
{
CheckForIllegalCrossThreadCalls = false;//dinamik nesne eklemek için listeye
}
1-)form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace dinamik
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Radiobtn_Click(object sender, EventArgs e)
{
}
static int arttir = 0;
private void button1_Click(object sender, EventArgs e)
{
// panel1.Controls.Clear(); //to remove all controls
// panel1.VerticalScroll.Value = VerticalScroll.Minimum;
RadioButton Radiobtn = new RadioButton();
Radiobtn.Name = "btn" + arttir;
Radiobtn.Text = "Remove";
Radiobtn.Location = new Point(1, 1+ arttir);
Radiobtn.Click += new EventHandler(Radiobtn_Click);
panel1.Controls.Add(Radiobtn);
arttir = arttir + 25;
}
}
}