在本文中我们给大家分享了关于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语言编程C++旋转字符操作串示例详解 2022-11-20
- C++实现ETW进行进程变动监控详解 2023-05-15
- C语言实现宾馆管理系统课程设计 2023-03-13
- C语言 详解字符串基础 2023-03-27
- 带你深度走入C语言取整以及4种函数 2022-09-17
- 全面了解C语言 static 关键字 2023-03-26
- centos 7 vscode cmake 编译c++工程 2023-09-17
- C++实战之二进制数据处理与封装 2023-05-29
- [c语言-函数]不定量参数 2023-09-08
- [C语言]二叉搜索树 2023-09-07
