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

华纳云-618大促3折起,18元/月买CN2 GIA 2M 香港云,物理机高防同享,10M带宽独享三网直连,无限流量!

官方网站:点击访问华纳云活动官网活动方案:一、香港云服务器此次推出八种配置的香港云服务器,满足不同行业不同业务规模的客户需求,同时每种配置的云服务都有不同的带宽选择,灵活性更高,可用性更强,性价比更优质。配置带宽月付6折季付5.5折半年付5折年付4.5折2年付4折3年付3折购买1H1G2M/99180324576648直达购买5M/17331556710081134直达购买2H2G2M892444...

LayerStack$10.04/月(可选中国香港、日本、新加坡和洛杉矶)高性能AMD EPYC (霄龙)云服务器,

LayerStack(成立于2017年),当前正在9折促销旗下的云服务器,LayerStack的云服务器采用第 3 代 AMD EPYC™ (霄龙) 处理器,DDR4内存和企业级 PCIe Gen 4 NVMe SSD。数据中心可选中国香港、日本、新加坡和洛杉矶!其中中国香港、日本和新加坡分为国际线路和CN2线路,如果选择CN2线路,价格每月要+3.2美元,付款支持paypal,支付宝,信用卡等!...

快快云:香港沙田CN2/美国Cera大宽带/日本CN2,三网直连CN2 GIA云服务器和独立服务器

快快云怎么样?快快云是一家成立于2021年的主机服务商,致力于为用户提供高性价比稳定快速的主机托管服务,快快云目前提供有香港云服务器、美国云服务器、日本云服务器、香港独立服务器、美国独立服务器,日本独立服务器。快快云专注为个人开发者用户,中小型,大型企业用户提供一站式核心网络云端服务部署,促使用户云端部署化简为零,轻松快捷运用云计算!多年云计算领域服务经验,遍布亚太地区的海量节点为业务推进提供强大...

selecteditem为你推荐
抓包什么是"抓包"?怎样"抓包"?显卡挖矿啥意思挖矿主板、挖矿显卡是什么意思?科来网络分析系统科来网络分析系统 6.0 专家版 (演示)的功能fcloseC语言文件关闭函数fclose(文件指针)是什么?知识库管理系统销售易CRM知识库,这是干什么用的?jdk6Java 中的 JDK 6 Update 6 到哪下载啊 ? 有一点急jqlJQL JINQILIN注册过商标吗?还有哪些分类可以注册?editplus破解版DBTools Manager Professional 破解版在哪里可以下载?spawningvc出现error spawning c1.exe怎么解决?民生电商民生电商与传统的电商有什么区别?
最便宜虚拟主机 美国主机网 好看的桌面背景图 长沙服务器 域名转向 metalink 酷番云 33456 超级服务器 美国凤凰城 英国伦敦 我的世界服务器ip 华为k3 阿里云邮箱登陆地址 cdn网站加速 实惠 北京主机托管 服务器托管价格 hdsky 镇江高防服务器 更多