This article will show you how to move all items from one
listbox to another in c#. Her I have
shown to move all item of one listbox to other in one click.
Some of my previous articles are as follows: Read
Outlook Email Subject Using c#, Read
Outlook Inbox Mail And Email Count Of Inbox Using C#.Net, How
To Read XML File In DataSet And Display in DataGridview Using C#.Net, WebBrowser
Control in C#, Windows Application, Change
Control Font Size At Runtime / Dynamically Using C#.Net and VB.Net In Windows
Application, Export
GridView Data To Excel Sheet Using C#.Net In Windows Application, Windows
Application In C#.Net (My first video article on youtube.com).
So for this article first we will create a new c#
application and add the listbox controls in it.
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;
namespace WindowsFormsApplication6
{
public partial class Form1 : Form
{
public
Form1()
{
InitializeComponent();
}
private
void Form1_Load(object
sender, EventArgs e)
{
}
/// <summary>
/// Move item from one list bo to other
/// </summary>
/// <param
name="sender"></param>
/// <param
name="e"></param>
private
void button1_Click(object
sender, EventArgs e)
{
for
(int i = 0; i < listBox1.Items.Count; i++)
{
listBox2.Items.Add(listBox1.Items[i].ToString());
}
listBox1.Items.Clear();
}
}
}
|
Now we have done run the application to check the output.
0 comments:
Please let me know your view