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

pacificrack7月美国便宜支持win VPS,$19.99/年,2G内存/1核/50gSSD/1T流量

pacificrack发布了7月最新vps优惠,新款促销便宜vps采用的是魔方管理,也就是PR-M系列。提一下有意思的是这次支持Windows server 2003、2008R2、2012R2、2016、2019、Windows 7、Windows 10,当然啦,常规Linux系统是必不可少的!1Gbps带宽、KVM虚拟、纯SSD raid10、自家QN机房洛杉矶数据中心...支持PayPal、...

Boomer.host:$4.95/年-512MB/5GB/500GB/德克萨斯州(休斯顿)

部落曾经在去年分享过一次Boomer.host的信息,商家自述始于2018年,提供基于OpenVZ架构的VPS主机,配置不高价格较低。最近,主机商又在LET发了几款特价年付主机促销,最低每年仅4.95美元起,有独立IPv4+IPv6,开设在德克萨斯州休斯顿机房。下面列出几款VPS主机配置信息。CPU:1core内存:512MB硬盘:5G SSD流量:500GB/500Mbps架构:KVMIP/面板...

织梦DEDECMS即将授权收费和维权模式 站长应对的几个方法

这两天在站长群里看到不少有使用DEDECMS织梦程序的朋友比较着急,因为前两天有看到来自DEDECMS,我们熟悉的织梦程序官方发布的公告,将会在10月25日开始全面商业用途的使用DEDECMS内容管理程序的会采用授权收费模式,如果我们有在个人或者企业商业用途的,需要联系且得到授权才可以使用,否则后面会通过维权的方式。对于这个事情,我们可能有些站长经历过,比如字体、图片的版权。以及有一些国内的CMS...

selecteditem为你推荐
查字网“很”去掉双人旁读什么?arc是什么意思数学中的arctan是什么意思jdk6我是win7的系统,安装了JDK6,环境配置都正确了。但是安装完没有应用程序啊~调度系统操作系统中为什么需要调度?vipjrvipjr怎么样?有真实体验的来说一下spawning为什么编译和运行vc++ 时会出现Error spawning c1.exe 的错误民生电商陆金所、民生电商哪个更适合投资?民生电商民生电商招的仓库操作工是干什么的layoutsubviewsios有没有类似tablayout的控件暴力破解密码用什么方法才能破解别人密码
抗投诉vps主机 美国主机排名 lamp 国外php主机 鲨鱼机 香港托管 中国电信宽带测速器 vul 畅行云 镇江高防 攻击服务器 重庆服务器 杭州电信宽带 免费赚q币 privatetracker 九零网络 alexa搜 ubuntu安装教程 ftp是什么东西 网络安装 更多