using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
string item = listBox1.SelectedItem.ToString();
int i = listBox1.SelectedIndex;
if (i == 0)
return;
listBox1.Items.Remove(listBox1.SelectedItem.ToString());
listBox1.Items.Insert(i - 1, item);
listBox1.SelectedIndex = i - 1;
}
catch (Exception)
{
MessageBox.Show("未选择项!");
在C#中实现listbox的项上下移动(winform)
最新推荐文章于 2019-07-02 11:11:46 发布