using System; using System.Drawing; using System.Windows.Forms; public class Form1 : Form { Button b = new Button(); ListBox listadoboz = new ListBox(); public Form1() { b.Text = "Kattints ide"; b.Click += new EventHandler(Button_Click); b.Location = new Point(112,20); listadoboz.Location = new Point(50,80); listadoboz.Size = new Size(200, 100); listadoboz.MultiColumn = false; //Többoszlopos listadoboz.SelectionMode = SelectionMode.MultiExtended; //Ez kell, hogy több elemet is ki lehessen jelölni. //Elem felvétele: listadoboz.Items.Add("Első"); listadoboz.Items.Add("Második"); listadoboz.Items.Add("Harmadik"); listadoboz.Items.Add("Negyedik"); // Több elem kijelölése: listadoboz.SetSelected(1, true); listadoboz.SetSelected(3, true); Controls.Add(b); Controls.Add(listadoboz); } static public void Main() { Application.Run(new Form1()); } private void Button_Click(object sender, EventArgs e) { MessageBox.Show(listadoboz.SelectedItems[0].ToString()); } }