vs2005制做左右上下移动的Listbox ( asp.net , C#)
来源:互联网 发布:人本帆布鞋 知乎 编辑:程序博客网 时间:2024/04/28 07:49
制作可上下左右移动的 ListBox:
方法:
1.新建页面,拖放如下控件: 两个ListBox ,6个button,样式如下
各个button的功能
>> 左移
<< 右移
↑上移
↓下移
C全部清空
>> 代码如下:
protected void Button1_Click(object sender, EventArgs e)
...{
try
...{
this.ListBox2.Items.Add(this.ListBox1.SelectedItem.Text.ToString());
}
catch (Exception)
...{
// this.Response.Write("<script language=javascript>alert('Please select some items before you click it!');history.go(-1)</script>");
}
}
<<代码如下:
protected void Button2_Click(object sender, EventArgs e)
...{
try
...{
this.ListBox2.Items.Remove(this.ListBox2.SelectedItem.Text.ToString());
}
catch (Exception)
...{
//this.Response.Write("<script language=javascript>alert('Please select some items before you click it!');history.go(-1)</script>");
}
}
↑代码如下:
protected void Button4_Click(object sender, EventArgs e)
...{
try
...{
int i = this.ListBox2.SelectedIndex;
int j = this.ListBox2.Items.Count;
if ((j > i) && (i != 0))
...{
string sitem = this.ListBox2.SelectedItem.Text.ToString();
this.ListBox2.Items.RemoveAt(i);
this.ListBox2.Items.Insert(i - 1, sitem);
this.ListBox2.SelectedIndex = i - 1;
}
}
catch (Exception)
...{
//this.Response.Write("<script language=javascript>alert('Please select some items before you click it!');history.go(-1)</script>");
}
}
↓代码如下:
protected void Button3_Click(object sender, EventArgs e)
...{
try
...{
int i = this.ListBox2.SelectedIndex;
int j = this.ListBox2.Items.Count;
if ((j > i) && (i != j - 1))
...{
string sitem = this.ListBox2.SelectedItem.Text.ToString();
this.ListBox2.Items.RemoveAt(i);
this.ListBox2.Items.Insert(i + 1, sitem);
this.ListBox2.SelectedIndex = i + 1;
}
}
catch (Exception)
...{
//this.Response.Write("<script language=javascript>alert('Please select some items before you click it!');history.go(-1)</script>");
}
}
C代码如下:
protected void Button6_Click(object sender, EventArgs e)
...{
this.ListBox2.Items.Clear();
}
最后显示如图:
方法:
1.新建页面,拖放如下控件: 两个ListBox ,6个button,样式如下
各个button的功能
>> 左移
<< 右移
↑上移
↓下移
C全部清空
>> 代码如下:
protected void Button1_Click(object sender, EventArgs e)
...{
try
...{
this.ListBox2.Items.Add(this.ListBox1.SelectedItem.Text.ToString());
}
catch (Exception)
...{
// this.Response.Write("<script language=javascript>alert('Please select some items before you click it!');history.go(-1)</script>");
}
}
<<代码如下:
protected void Button2_Click(object sender, EventArgs e)
...{
try
...{
this.ListBox2.Items.Remove(this.ListBox2.SelectedItem.Text.ToString());
}
catch (Exception)
...{
//this.Response.Write("<script language=javascript>alert('Please select some items before you click it!');history.go(-1)</script>");
}
}
↑代码如下:
protected void Button4_Click(object sender, EventArgs e)
...{
try
...{
int i = this.ListBox2.SelectedIndex;
int j = this.ListBox2.Items.Count;
if ((j > i) && (i != 0))
...{
string sitem = this.ListBox2.SelectedItem.Text.ToString();
this.ListBox2.Items.RemoveAt(i);
this.ListBox2.Items.Insert(i - 1, sitem);
this.ListBox2.SelectedIndex = i - 1;
}
}
catch (Exception)
...{
//this.Response.Write("<script language=javascript>alert('Please select some items before you click it!');history.go(-1)</script>");
}
}
↓代码如下:
protected void Button3_Click(object sender, EventArgs e)
...{
try
...{
int i = this.ListBox2.SelectedIndex;
int j = this.ListBox2.Items.Count;
if ((j > i) && (i != j - 1))
...{
string sitem = this.ListBox2.SelectedItem.Text.ToString();
this.ListBox2.Items.RemoveAt(i);
this.ListBox2.Items.Insert(i + 1, sitem);
this.ListBox2.SelectedIndex = i + 1;
}
}
catch (Exception)
...{
//this.Response.Write("<script language=javascript>alert('Please select some items before you click it!');history.go(-1)</script>");
}
}
C代码如下:
protected void Button6_Click(object sender, EventArgs e)
...{
this.ListBox2.Items.Clear();
}
最后显示如图:
- vs2005制做左右上下移动的Listbox ( asp.net , C#)
- vs2005制做左右上下移动的Listbox ( asp.net , C#)
- 原创:在visual studio 2005 中制做 左右上下移动 的 Listbox ( asp.net , C#)
- ASP.NET ListBox的使用与其上下移动方法
- Javascript控制Listbox左右/上下移动方法集合
- .net C# listbox的上下移动,拖动排序,两个listbox相互拖动
- 如何在asp.net中实现listbox item值上下移动?(转)
- asp.net中两个ListBox 左右互相移动,以及上移、下移
- asp.net中两个ListBox 左右互相移动,以及上移、下移 .
- ListBox实现上下移动
- 列表框的左右上下移动
- ASP.NET treeview 树控件的节点上下移动
- 【js】左右上下移动
- ListBox中的SelectedItem上下移动
- asp.net DropDownList值上下移动
- 将ListBox选中的项进行上下移动
- jquery实现左右上下移动
- C#.NET常见问题(FAQ)-SplitPanel如何设置上下和左右
- Windows XP的星期显示的设置过程
- 别让Hibernate偷走了您的身份
- javaScript技巧集合
- 如何编写代码才能使得效率高
- netstat命令解释
- vs2005制做左右上下移动的Listbox ( asp.net , C#)
- C#中的delegate和event
- 周一上班
- 监视tomcat是否正常,不正常重启
- Ajax上的对浏览器的判断
- 查看硬件、删除日志脚本
- mysql自动备份脚本
- tomcat优化总结
- 简单防范SYN_RECV攻击