Skip to content

Instantly share code, notes, and snippets.

@jskeet
Created August 11, 2017 09:58
Show Gist options
  • Save jskeet/57d2ff6660c8b3526c2de8f2d99b3b72 to your computer and use it in GitHub Desktop.
Save jskeet/57d2ff6660c8b3526c2de8f2d99b3b72 to your computer and use it in GitHub Desktop.
using System;
using System.Drawing;
using System.Windows.Forms;
public class Test
{
static void Main()
{
Button button = new Button
{
Text = "Click",
Location = new Point(10, 50)
};
ListBox list = new ListBox
{
Items = { "first", "second", "third" },
Location = new Point(10, 100),
SelectionMode = SelectionMode.MultiExtended
};
button.Click += delegate
{
Console.WriteLine("Selected items:");
foreach (var item in list.SelectedItems)
{
Console.WriteLine(item);
}
};
Form form = new Form
{
Size = new Size(300, 300),
Controls = { button, list }
};
Application.Run(form);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment