vb listview控件中如何在选中某一行时将此行的第3列数据提取到文本框中显示,急!
展开全部
Dim i As Integer
Private Sub Command1_Click()
With ListView1.ListItems.Add
.SubItems(1) = i & "a"
.SubItems(2) = i & "b"
.SubItems(3) = i & "c"
End With
i = i + 1
End Sub
Private Sub Command2_Click()
Text1.Text = ListView1.SelectedItem.SubItems(3)
End Sub
Private Sub Form_Load()
ListView1.View = lvwReport
ListView1.ColumnHeaders.Clear
With ListView1.ColumnHeaders
.Add , , "", 10
.Add , , "第一列", 1000
.Add , , "第二列", 2000
.Add , , "第三列", 2000
End With
i = 1
End Sub
Private Sub Command1_Click()
With ListView1.ListItems.Add
.SubItems(1) = i & "a"
.SubItems(2) = i & "b"
.SubItems(3) = i & "c"
End With
i = i + 1
End Sub
Private Sub Command2_Click()
Text1.Text = ListView1.SelectedItem.SubItems(3)
End Sub
Private Sub Form_Load()
ListView1.View = lvwReport
ListView1.ColumnHeaders.Clear
With ListView1.ColumnHeaders
.Add , , "", 10
.Add , , "第一列", 1000
.Add , , "第二列", 2000
.Add , , "第三列", 2000
End With
i = 1
End Sub
追问
谢谢 1 再问一下如何在某行某列中添加数据 如在第三行第二列添加text1中的数据
2还有上面的问题你是在按钮中添加的命令,如何点击此行时即在text1中显示此行的第三列数据,不用点击按钮。
3选中某行的函数有没有返回值,比如说选中一行时有个返回值,我好在其他的控件中引用 谢谢 给你加分
追答
Dim i As Integer
Private Sub Command1_Click()
With ListView1.ListItems.Add
.SubItems(1) = i & "a"
.SubItems(2) = i & "b"
.SubItems(3) = i & "c"
End With
i = i + 1
End Sub
Private Sub Command2_Click()
Text1.Text = ListView1.SelectedItem.SubItems(3)
End Sub
Private Sub Command3_Click()
ListView1.ListItems(3).SubItems(2) = Text2.Text
End Sub
Private Sub Form_Load()
ListView1.View = lvwReport
ListView1.ColumnHeaders.Clear
With ListView1.ColumnHeaders
.Add , , "", 10
.Add , , "第一列", 1000
.Add , , "第二列", 2000
.Add , , "第三列", 2000
End With
i = 1
End Sub
Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)
Text1.Text = ListView1.SelectedItem.SubItems(3)
End Sub
ListView1.SelectedItem.Index 这个就是你当前选中的行!~
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
不清出你的具体格式,暂且认为:
1 A a
2 B b
3 C c
每个字符间有一个空格,每行的后面(如小a后面)都有一个空格,代码如下
Private Sub Command1_Click()
Dim tmpGrp() As String '用于存放分解后的text1内容
tmpGrp = Split(Text1.Text, " ")
Dim i As Integer
Dim tmpRst As String
For i = 0 To UBound(tmpGrp) Step 3
If i + 1 < UBound(tmpGrp) Then
tmpRst = tmpRst & IIf(tmpRst = "", "", vbCrLf) & tmpGrp(i + 1)
End If
Next i
Text2.Text = tmpRst
End Sub
1 A a
2 B b
3 C c
每个字符间有一个空格,每行的后面(如小a后面)都有一个空格,代码如下
Private Sub Command1_Click()
Dim tmpGrp() As String '用于存放分解后的text1内容
tmpGrp = Split(Text1.Text, " ")
Dim i As Integer
Dim tmpRst As String
For i = 0 To UBound(tmpGrp) Step 3
If i + 1 < UBound(tmpGrp) Then
tmpRst = tmpRst & IIf(tmpRst = "", "", vbCrLf) & tmpGrp(i + 1)
End If
Next i
Text2.Text = tmpRst
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
楼上很正确,我也学习了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询