mwfd.net
当前位置:首页 >> 如何在VB.NET ListViEw获取已选中单元格所在的列? >>

如何在VB.NET ListViEw获取已选中单元格所在的列?

Private Sub ListViewSelectedIndexChanged(sender As Object, e As EventArgs) _ Handles ListView1.SelectedIndexChanged If ListView1.SelectedIndices.Count > 0 Then Dim index As Integer = ListView1.SelectedIndices(0) + 1 '选中行的下一行索引 If index 评论0 0 0

ListView1.SelectedItems(0)

你可以在SELECTCHANGED方法里的SELECTROW之类的字样的方法里获取被选种行.然后通过INDEX获得第一列的信息

Private Sub Command1_Click() Text1.Text = "" For i = 1 To ListView1.ListItems.Count If ListView1.ListItems(i).Checked Then Text1.Text = Text1.Text & ListView1.ListItems(i).SubItems(2) & "," End If Next Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1)End Sub

Private Sub List1_Click()MsgBox "你单击的是第" & List1.ListIndex + 1 & "行"End Sub

textbox1.text=listview1.selectitem.subitems.item(指定的列索引).text

你要vb.net版的还是c#版的?下面是vb.net版的:dim i as integer=listview.items.indexof(listview.focuseditem)'首先获得选中项的索引msgbox(listview.items(i).subitems(0).text)'弹出消息框显示所选择项的第0列的文本

Private Sub ListView1_Click() If ListView1.ListItems.Count > 0 Then Text1.Text = ListView1.SelectedItem.Text Text2.Text = ListView1.SelectedItem.SubItems(1) Text3.Text = ListView1.SelectedItem.SubItems(2) Text4.Text = ListView1.SelectedItem.

it.SubItems(2) 就是第三列的值 it.SubItems(4) 就是第五列的值

用msflexgrid 吧,这个功能全,能实现你说的.

ddgw.net | 90858.net | hyqd.net | nwlf.net | knrt.net | 网站首页 | 网站地图
All rights reserved Powered by www.mwfd.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com