C# listview 控件中,以列表呈现,如何获取选中的某一项的名称 20

这张图片是我做出来的效果图,当鼠标选中某一项的时候,可以获取该项的名称。当鼠标选中另外一项,再获取当前项的名称。。。。就是这个意思... 这张图片是我做出来的效果图,当鼠标选中某一项的时候,可以获取该项的名称。
当鼠标选中另外一项,再获取当前项的名称。。。。就是这个意思
展开
 我来答
21d801
2011-08-06 · TA获得超过660个赞
知道小有建树答主
回答量:830
采纳率:100%
帮助的人:929万
展开全部
ListView listView1 = new ListView();
listView1.Bounds = new Rectangle(new Point(10,10), new Size(300,200));

// Set the view to show details.
listView1.View = View.Details;
// Allow the user to edit item text.
listView1.LabelEdit = true;
// Allow the user to rearrange columns.
listView1.AllowColumnReorder = true;
// Display check boxes.
listView1.CheckBoxes = true;
// Select the item and subitems when selection is made.
listView1.FullRowSelect = true;
// Display grid lines.
listView1.GridLines = true;
// Sort the items in the list in ascending order.
listView1.Sorting = SortOrder.Ascending;

// Create three items and three sets of subitems for each item.
ListViewItem item1 = new ListViewItem("item1",0);
// Place a check mark next to the item.
item1.Checked = true;
item1.SubItems.Add("1");
item1.SubItems.Add("2");
item1.SubItems.Add("3");
ListViewItem item2 = new ListViewItem("item2",1);
item2.SubItems.Add("4");
item2.SubItems.Add("5");
item2.SubItems.Add("6");
ListViewItem item3 = new ListViewItem("item3",0);
// Place a check mark next to the item.
item3.Checked = true;
item3.SubItems.Add("7");
item3.SubItems.Add("8");
item3.SubItems.Add("9");

// Create columns for the items and subitems.
listView1.Columns.Add("Item Column", -2, HorizontalAlignment.Left);
listView1.Columns.Add("Column 2", -2, HorizontalAlignment.Left);
listView1.Columns.Add("Column 3", -2, HorizontalAlignment.Left);
listView1.Columns.Add("Column 4", -2, HorizontalAlignment.Center);
百度网友9afa247d8
2011-08-06 · TA获得超过685个赞
知道小有建树答主
回答量:743
采纳率:0%
帮助的人:641万
展开全部
好像是应该获取某个根节点,然后遍历查找吧,以前弄过
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式