在本文中我们给大家分享了关于C#的ListBox中的Item拖拽的功能代码分享,对此有需要的朋友参考学习下。
我们先来看下运行效果图
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)
{
//单选,无法实现多选
//string str = this.listBox1.Text.Trim().ToString();
//if (listBox1.Items.Contains(str))
//{
// listBox1.Items.Remove(str);
// listBox2.Items.Add(str);
/
沃梦达教程
本文标题为:C# ListBox中的Item拖拽代码分享


基础教程推荐
猜你喜欢
- C语言 structural body结构体详解用法 2022-12-06
- C/C++编程中const的使用详解 2023-03-26
- 一文带你了解C++中的字符替换方法 2023-07-20
- C语言基础全局变量与局部变量教程详解 2022-12-31
- C++中的atoi 函数简介 2023-01-05
- 详解c# Emit技术 2023-03-25
- C++使用easyX库实现三星环绕效果流程详解 2023-06-26
- C利用语言实现数据结构之队列 2022-11-22
- 如何C++使用模板特化功能 2023-03-05
- C++详细实现完整图书管理功能 2023-04-04