我們先來(lái)看下運(yùn)行效果圖


Form1.cs代碼:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Collections;
namespace MoveItem
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
ArrayList list = new ArrayList();
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
for (int i = 1; i <= 10; i++)
{
list.Add(i);
string s = i.ToString();
listBox1.Items.Add(s);
}
}
private void listBox2_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
//單選,無(wú)法實(shí)現(xiàn)多選
//string str = this.listBox1.Text.Trim().ToString();
//if (listBox1.Items.Contains(str))
//{
// listBox1.Items.Remove(str);
// listBox2.Items.Add(str);
//}
for (int i=0;i<listBox1.SelectedIndices.Count;i++)
{
listBox2.Items.Add(listBox1.Items[listBox1.SelectedIndices[i]]);
listBox1.Items.RemoveAt(listBox1.SelectedIndices[i]);
i--;
}
}
private void button2_Click(object sender, EventArgs e)
{
for (int i = 0; i < listBox2.SelectedIndices.Count; i++)
{
listBox1.Items.Add(listBox2.Items[listBox2.SelectedIndices[i]]);
listBox2.Items.RemoveAt(listBox2.SelectedIndices[i]);
i--;
}
}
private void button3_Click(object sender, EventArgs e)
{
listBox2.Items.AddRange(listBox1.Items);
listBox1.Items.Clear();
}
private void button4_Click(object sender, EventArgs e)
{
listBox1.Items.AddRange(listBox2.Items);
listBox2.Items.Clear();
}
}
}另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專(zhuān)為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
分享文章:C#ListBox中的Item拖拽代碼分享-創(chuàng)新互聯(lián)
網(wǎng)站地址:http://chinadenli.net/article48/dighhp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供Google、網(wǎng)站導(dǎo)航、用戶體驗(yàn)、面包屑導(dǎo)航、域名注冊(cè)、云服務(wù)器
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容
營(yíng)銷(xiāo)型網(wǎng)站建設(shè)知識(shí)