C#ListBox中的Item拖拽代码分享

我们先来看下运行效果图

创新互联专业提供成都服务器托管服务,为用户提供五星数据中心、电信、双线接入解决方案,用户可自行在线购买成都服务器托管服务,并享受7*24小时金牌售后服务。

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);
      //}
      for (int i=0;i

大家可以测试运行下,有其他问题可以在下方的留言区讨论,感谢大家对创新互联的支持。


当前题目:C#ListBox中的Item拖拽代码分享
网页路径:http://hxwzsj.com/article/ispsgi.html

其他资讯

Copyright © 2025 青羊区翔捷宏鑫字牌设计制作工作室(个体工商户) All Rights Reserved 蜀ICP备2025123194号-14
友情链接: 成都网站建设 营销网站建设 网站建设改版 成都企业网站建设 成都网站制作 企业网站制作 响应式网站建设 成都网站建设推广 网站制作 响应式网站设计方案 成都企业网站设计 营销型网站建设 成都h5网站建设 网站建设推广 重庆网站制作 LED网站设计方案 盐亭网站设计 成都商城网站制作 专业网站设计 成都网站建设公司 成都网站建设 成都品牌网站建设