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(); } }

Raksmart:香港高防服务器/20Mbps带宽(cn2+bgp)/40G-100Gbps防御

RAKsmart怎么样?RAKsmart香港机房新增了付费的DDoS高防保护服务,香港服务器默认接入20Mbps的大陆优化带宽(电信走CN2、联通和移动走BGP)。高防服务器需要在下单页面的IP Addresses Option里面选择购买,分:40Gbps大陆优化高防IP-$461/月、100Gbps国际BGP高防IP-$692/月,有兴趣的可以根据自己的需求来选择!点击进入:RAKsmart官...

bgpto:BGP促销,日本日本服务器6.5折$93/月低至6.5折、$93/月

bgpto怎么样?bgp.to日本机房、新加坡机房的独立服务器在搞特价促销,日本独立服务器低至6.5折优惠,新加坡独立服务器低至7.5折优惠,所有优惠都是循环的,终身不涨价。服务器不限制流量,支持升级带宽,免费支持Linux和Windows server中文版(还包括Windows 10). 特色:自动部署,无需人工干预,用户可以在后台自己重装系统、重启、关机等操作!bgpto主打日本(东京、大阪...

RAKsmart秒杀服务器$30/月,洛杉矶/圣何塞/香港/日本站群特价

RAKsmart发布了9月份优惠促销活动,从9月1日~9月30日期间,爆款美国服务器每日限量抢购最低$30.62-$46/月起,洛杉矶/圣何塞/香港/日本站群大量补货特价销售,美国1-10Gbps大带宽不限流量服务器低价热卖等。RAKsmart是一家华人运营的国外主机商,提供的产品包括独立服务器租用和VPS等,可选数据中心包括美国加州圣何塞、洛杉矶、中国香港、韩国、日本、荷兰等国家和地区数据中心(...

selecteditem为你推荐
weakhashmap在Java中ArrayList、LinkedList、HashMap的区别是什么知识库管理系统什么是知识管理bindservice如何启动和停止用servicetvosairpods什么意思 airpods连接方式是怎样的jdk6JDK6和JDK7两个版本有什么区别,初学者选那个好?天融信防火墙天融信下一代防火墙有那些特点和优势?inode智能客户端win7如何使用校园网iNode智能客户端php论坛怎样快速在个人电脑上建立一个自己的PHP论坛服务器?layoutsubviewsios有没有类似tablayout的控件药品标准查询《中华人民名共和国卫生部药品标准》【20080802】?
免费com域名注册 3322免费域名 息壤主机 edis unsplash 正版win8.1升级win10 12u机柜尺寸 dd444 中国网通测速 天翼云盘 微软服务器操作系统 香港亚马逊 web服务器搭建 宏讯 什么是web服务器 服务器防火墙 supercache 云服务是什么意思 hostease xshell5注册码 更多