megatron
12.Ocak.2015, 22:27
GroupBox içindeki seçili CheckBox’ları ListBox’a ekle C#
Kod:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace groupbox_secili_checkbox_listbox_ekle
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnEkle_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
foreach (Control kontrol in this.groupBox1.Controls)
{
if (kontrol is CheckBox)
{
if (((CheckBox)kontrol).Checked == true)
{
listBox1.Items.Add( ((CheckBox)kontrol).Text.ToString());
}
}
}
}
}
}
Kod:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace groupbox_secili_checkbox_listbox_ekle
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnEkle_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
foreach (Control kontrol in this.groupBox1.Controls)
{
if (kontrol is CheckBox)
{
if (((CheckBox)kontrol).Checked == true)
{
listBox1.Items.Add( ((CheckBox)kontrol).Text.ToString());
}
}
}
}
}
}