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(); }
VulpesPosted Feb 8, 2012, 6:40 PM
Sam HobbsPosted Feb 10, 2012, 2:28 AM
Csharp NinjaPosted Feb 8, 2012, 7:10 PM
Cheers
Csharp NinjaPosted Feb 8, 2012, 6:15 PM
Satyapriya NayakPosted Feb 6, 2012, 10:21 PM
Try this...
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 button1_Click(object sender, EventArgs e)
{
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
StreamWriter sw = new StreamWriter(saveFileDialog1.FileName);
foreach (object item in listBox1.Items)
sw.WriteLine(item.ToString());
sw.Close();
MessageBox.Show("Listbox items copied");
}
}
}
}
Thanks