Copy Listbox items to Clipboard

Satyapriyanayak
Posted by Satyapriyanayak under C# category on | Points: 40 | Views : 3997
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;
using System.IO;

namespace listbox_copy
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}


private void Form1_Load(object sender, EventArgs e)
{
listBox1.Items.Add("a");
listBox1.Items.Add("b");
listBox1.Items.Add("c");
}



private void btncopy_Click(object sender, EventArgs e)
{
string s1 = "";
foreach (object item in listBox1.Items) s1 += item.ToString() + "\r\n";
Clipboard.SetText(s1);
}
}
}

Comments or Responses

Login to post response