selecteditemListView选中selectedItem怎么实现上下移动

selecteditem  时间:2021-07-02  阅读:()

ListBoxItem selectedType = (type.SelectedItem as ListBoxItem); 什么意思啊?

其实就是将type 控件的SelectedItem 赋值给一个新定义的selectedType 变量 type.SelectedItem as ListBoxItem并进行了类型转换

TreeView1.SelectedItem.Index

Dim tNode As Node Set tNode = TreeView1.Nodes.Add ("key2",wChild, "key13", "Display[ON]", 3) Msgbox tNode.Index

DropDownList1.SelectedItem.Text 取值

直接使用DropDownList1.Text就可以了,没必要使用SelectedItem。

至于为什么SelectedItem有问题,今天太累了,就不琢磨了。

改天吧。

英语翻译//GetNextSelectedItem

通过调用GetNextSelectedItem || GetFirstSelectedItemPosition方法来返回position值的引用。

下一个position的值就通过此方法被附上了。

----你用有道词典查吧 别在这浪费时间提问了

listbox的用法

C#中ListBox控件的用法 1. 属性列表: SelectionMode 组件中条目的选择类型,即多选(Multiple)、单选(Single) Rows 列表框中显示总共多少行 Selected 检测条目是否被选中 SelectedItem 返回的类型是ListItem,获得列表框中被选择的条目 Count 列表框中条目的总数 SelectedIndex 列表框中被选择项的索引值 Items 泛指列表框中的所有项,每一项的类型都是ListItem 2. 取列表框中被选中的值 ListBox.SelectedValue 3. 动态的添加列表框中的项: ListBox.Items.Add("所要添加的项"); 4. 移出指定项: //首先判断列表框中的项是否大于0 If(ListBox.Items.Count > 0 ) { //移出选择的项 ListBox.Items.Remove(ListBox.SelectedItem); } 5. 清空所有项: //首先判断列表框中的项是否大于0 If(ListBox.Items.Count > 0 ) { //清空所有项 ListBox.Items.Clear(); } 6. 列表框可以一次选择多项: 只需设置列表框的属性 SelectionMode="Multiple",按Ctrl可以多选 7. 两个列表框联动,即两级联动菜单 //判断第一个列表框中被选中的值 switch(ListBox1.SelectValue) { //如果是"A",第二个列表框中就添加这些: case "A" ListBox2.Items.Clear(); ListBox2.Items.Add("A1"); ListBox2.Items.Add("A2"); ListBox2.Items.Add("A3"); //如果是"B",第二个列表框中就添加这些: case "B" ListBox2.Items.Clear(); ListBox2.Items.Add("B1"); ListBox2.Items.Add("B2"); ListBox2.Items.Add("B3"); } 8. 实现列表框中项的移位 即:向上移位、向下移位 具体的思路为:创建一个ListBox对象,并把要移位的项先暂放在这个对象中。

如果是向上移位,就是把当前选定项的的上一项的值赋给当前选定的项,然后 把刚才新加入的对象的值,再附给当前选定项的前一项。

具体代码为: //定义一个变量,作移位用 index = -1; //将当前条目的文本以及值都保存到一个临时变量里面 ListItem lt=new ListItem (ListBox.SelectedItem.Text,ListBox.SelectedValue); //被选中的项的值等于上一条或下一条的值 ListBox.Items[ListBox.SelectedIndex].Text=ListBox.Items[ListBox.SelectedIndex + index].Text; //被选中的项的值等于上一条或下一条的值 ListBox.Items[ListBox.SelectedIndex].Value=ListBox.Items[ListBox.SelectedIndex + index].Value; //把被选中项的前一条或下一条的值用临时变量中的取代 ListBox.Items[ListBox.SelectedIndex].Test=lt.Test; //把被选中项的前一条或下一条的值用临时变量中的取代 ListBox.Items[ListBox.SelectedIndex].Value=lt.Value; //把鼠标指针放到移动后的那项上 ListBox.Items[ListBox.SelectedIndex].Value=lt.Value; 9. 移动指针到指定位置: (1).移至首条 //将被选中项的索引设置为0就OK了 ListBox.SelectIndex=0; (2).移至尾条 //将被选中项的索引设置为ListBox.Items.Count-1就OK了 ListBox.SelectIndex=ListBox.Items.Count-1; (3).上一条 //用当前被选中的索引去减 1 ListBox.SelectIndex=ListBox.SelectIndex - 1; (4).下一条 //用当前被选中的索引去加 1 ListBox.SelectIndex=ListBox.SelectIndex + 1; this.ListBox1.Items.Insertat(3,new ListItem("插入在第3行之后项","")); this.ListBox1.Items.Insertat(index,ListItem) ListBox1.Items.Insert(0,new ListItem("text","value"));

ListView选中selectedItem怎么实现上下移动

private void ListViewUpMove(ListView listView) { if (listView.SelectedItems.Count == 0) { return; }

listView.BeginUpdate(); if (listView.SelectedItems[0].Index > 0) { foreach (ListViewItem lvi in listView.SelectedItems) { ListViewItem lviSelectedItem = lvi; int indexSelectedItem = lvi.Index; listView.Items.RemoveAt(indexSelectedItem); listView.Items.Insert(indexSelectedItem - 1, lviSelectedItem); } } listView.EndUpdate();

if (listView.Items.Count > 0 && listView.SelectedItems.Count > 0) { listView.Focus(); listView.SelectedItems[0].Focused = true; listView.SelectedItems[0].EnsureVisible(); }

}

=============================================================

//下移 private void ListViewDownMove(ListView listView) { if (listView.SelectedItems.Count == 0) { return; }

listView.BeginUpdate(); int indexMaxSelectedItem = listView.SelectedItems[listView.SelectedItems.Count - 1].Index;

if (indexMaxSelectedItem < listView.Items.Count - 1) { for (int i = listView.SelectedItems.Count - 1; i >= 0; i--) { ListViewItem lviSelectedItem = listView.SelectedItems[i]; int indexSelectedItem = lviSelectedItem.Index; listView.Items.RemoveAt(indexSelectedItem); listView.Items.Insert(indexSelectedItem + 1, lviSelectedItem); } } listView.EndUpdate();

if (listView.Items.Count > 0 && listView.SelectedItems.Count > 0) { listView.Focus(); listView.SelectedItems[listView.SelectedItems.Count - 1].Focused = true; listView.SelectedItems[listView.SelectedItems.Count - 1].EnsureVisible(); } }

统计一下racknerd正在卖的超便宜VPS,值得推荐的便宜美国VPS

racknerd从成立到现在发展是相当迅速,用最低的价格霸占了大部分低端便宜vps市场,虽然VPS价格便宜,但是VPS的质量和服务一点儿都不拉跨,服务器稳定、性能给力,尤其是售后方面时间短技术解决能力强,估计这也是racknerd这个品牌能如此成功的原因吧! 官方网站:https://www.racknerd.com 多种加密数字货币、信用卡、PayPal、支付宝、银联、webmoney,可...

Sharktech($49/月),10G端口 32GB内存,鲨鱼机房新用户赠送$50

Sharktech 鲨鱼机房商家我们是不是算比较熟悉的,因为有很多的服务商渠道的高防服务器都是拿他们家的机器然后部署高防VPS主机的,不过这几年Sharktech商家有自己直接销售云服务器产品,比如看到有新增公有云主机有促销活动,一般有人可能买回去自己搭建虚拟主机拆分销售的,有的也是自用的。有看到不少网友在分享到鲨鱼机房商家促销活动期间,有赠送开通公有云主机$50,可以购买最低配置的,$49/月的...

MineServer:香港CMI/洛杉矶GIA VPS,2核/2GB内存/20GB NVME/3.5TB流量/200Mbps/KVM,288元/年

mineserver怎么样?mineserver是一家国人商家,主要提供香港CN2 KVM VPS、香港CMI KVM VPS、日本CN2 KVM VPS、洛杉矶cn2 gia端口转发等服务,云服务器网(yuntue.com)介绍过几次,最近比较活跃。现在新推出了3款特价KVM VPS,性价比高,香港CMI/洛杉矶GIA VPS,2核/2GB内存/20GB NVME/3.5TB流量/200Mbps...

selecteditem为你推荐
诺诺云代账上海的亮证节有讲到诺诺云代账,产品如何?微信收款语音播报怎么设置两部手机微信收款语音播报怎么设置拓扑关系拓扑关系在GIS中的作用备忘录模式Java中常用的设计模式有哪些?请详细说明一下工厂模式。调度系统1.说明高级调度、中级调度和低级调度的基本含义。索引超出了数组界限索引超出了数组界限是怎么回事啊?索引超出了数组界限什么是索引超出了数组界限layoutsubviewsios有没有类似tablayout的控件cf加速器玩cf ping高用什么加速器比较好qq业务中心QQ业务办理
虚拟主机测评 北京域名注册 阿里云邮箱登陆首页 a2hosting westhost 安云加速器 NetSpeeder 服务器维护方案 服务器合租 福建铁通 服务器硬件防火墙 安徽双线服务器 智能dns解析 国外在线代理服务器 论坛主机 群英网络 网络速度 mteam comodo easypanel 更多