在listbox中,如何得到选定的项的内容?

lufeng 2003-12-12 05:20:18
谢谢!

在线等待!
...全文
62 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
lufeng 2003-12-13
  • 打赏
  • 举报
回复

谢谢!!
lufeng 2003-12-13
  • 打赏
  • 举报
回复
谢谢!!
lifeforu 2003-12-12
  • 打赏
  • 举报
回复
GetText(GetCurSel(),csText);
^_^
wyb_45 2003-12-12
  • 打赏
  • 举报
回复
招聘:
熟悉
1、VC++
2、swing
3、java
有上述工具使用1-2年以上


北京友联创新系统集成有限公司
联系方式:
010-62984859-0或8000
或010-82899479
联系人:包小姐
ylcxkj@vip.sina.com
lifeforu 2003-12-12
  • 打赏
  • 举报
回复
GetText(nIndex,csText);
^_^
Cline 2003-12-12
  • 打赏
  • 举报
回复
CString csText;
nIndex=2;
GetItemText(nIndex,csText);//
QQ好友例表控件 带实例和源码 //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"));

16,551

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧