如何在标签列表中向上或向下移动标签,c#&视觉工作室 [英] How to move label up or down in label lists, c# & visual studio

查看:222
本文介绍了如何在标签列表中向上或向下移动标签,c#&视觉工作室的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好

我的应用程序从数据库中检索数据并一个接一个地显示为标签。我想知道如何在列表中单击鼠标来上移或下移标签。

My application retrieves data from database and displays as label one after another. I want to know how a label is moved up or down with a mouse click in the list.

 我不想在表单周围移动标签。我只想通过鼠标点击在列表中上下移动标签。

 I dont want to move label around the form. I want only to move the label up and down in the list with mouse click.

推荐答案

  private void Up_Click(object sender, EventArgs e)
        {
            var index = checkedListBox1.SelectedIndex;
            if (index != 0)
            {
                var temp = checkedListBox1.Items[index-1];
                checkedListBox1.Items[index - 1] = checkedListBox1.Text;
                checkedListBox1.Items[index] = temp;
            }
        }

这是列表代码。选择一个项目,然后单击向上按钮。它会上升 

Here is List up code. Select an item and click up button. It will going up 


这篇关于如何在标签列表中向上或向下移动标签,c#&视觉工作室的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆