在本文中我们给大家分享了关于C#的ListBox中的Item拖拽的功能代码分享,对此有需要的朋友参考学习下。
我们先来看下运行效果图
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语言详解float类型在内存中的存储方式 2023-03-27
- Qt计时器使用方法详解 2023-05-30
- C语言qsort()函数的使用方法详解 2023-04-26
- ubuntu下C/C++获取剩余内存 2023-09-18
- 我应该为我的项目使用相对包含路径,还是将包含目录放在包含路径上? 2022-10-30
- C语言手把手带你掌握带头双向循环链表 2023-04-03
- C++ 数据结构超详细讲解顺序表 2023-03-25
- 详解C语言中sizeof如何在自定义函数中正常工作 2023-04-09
- Easyx实现扫雷游戏 2023-02-06
- c++ const 成员函数,返回一个 const 指针.但是返回的指针是什么类型的 const? 2022-10-11