How to copy selected item in list box in C#?
c#, clipboard, copy, list
Solution
If you want to select an item, and do ctrl + c then use this code:
private void listBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.Control == true && e.KeyCode == Keys.C)
{
string s = listBox1.SelectedItem.ToString();
Clipboard.SetData(DataFormats.StringFormat, s);
}
}
Problem
How to copy selected item in list box to clipboard, using right click "Copy" menu?