[VB]在listview的第i行第j列显示数值

unsv29mj 2010-03-25 04:47:49
[VB]在listview的第i行第j列显示数值

多谢各位!!
...全文
227 20 打赏 收藏 转发到动态 举报
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
ning1958 2010-05-08
  • 打赏
  • 举报
回复
Private Sub Command1_Click()
Dim xx As ListItem
Set xx = ListView1.ListItems.Add(, , "111")
With xx
.SubItems(1) = "ff"
.SubItems(2) = "ddff"
End With
End Sub

Private Sub Form_Load()
ListView1.View = lvwReport
ListView1.ColumnHeaders.Add , , "第1列", 1000
ListView1.ColumnHeaders.Add , , "第2列", 1000
ListView1.ColumnHeaders.Add , , "第3列", 1000
End Sub
bcrun 2010-03-31
  • 打赏
  • 举报
回复
类似别人代码中的List1,你从“部件”里拖一个Microsoft FlexGrid Control 6.0 (SP6)到窗体上就行了
bcrun 2010-03-31
  • 打赏
  • 举报
回复
[Quote=引用 16 楼 unsv29mj 的回复:]

Private Sub FillData()
Dim iRow As Integer, iCol As Integer
With MSFlexGrid1
.Rows = 10 '将表格设置为10行高……


程序有错误 变量没定义
[/Quote]

晕,楼主赶紧加油打基础吧
unsv29mj 2010-03-26
  • 打赏
  • 举报
回复
[Quote=引用 15 楼 bcrun 的回复:]
引用 14 楼 unsv29mj 的回复:

请弄个简单的msflexgrid出来吧 多谢!

看看有多简单?


VB code

Private Sub FillData()
Dim iRow As Integer, iCol As Integer
With MSFlexGrid1
.Rows = 10 '将表格设置为10行高,包括固定……
[/Quote]

程序有错误 变量没定义
bcrun 2010-03-26
  • 打赏
  • 举报
回复
[Quote=引用 14 楼 unsv29mj 的回复:]

请弄个简单的msflexgrid出来吧 多谢!

看看有多简单?
[/Quote]


Private Sub FillData()
Dim iRow As Integer, iCol As Integer
With MSFlexGrid1
.Rows = 10 '将表格设置为10行高,包括固定行
.Cols = 4
.Row = 0 '定位到第一行
'修改3列的标题
.Col = 1: .CellFontBold = True: .Text = "编号"
.Col = 2: .CellFontBold = True: .Text = "名称"
.Col = 3: .CellFontBold = True: .Text = "地址"
For iRow = 1 To .Rows - 1 '对每行第一列赋值
.Row = iRow
.Col = 1: .Text = CStr(iRow)
Next iRow


End With
End Sub
unsv29mj 2010-03-26
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 jhone99 的回复:]
引用 10 楼 unsv29mj 的回复:
既然listview这么麻烦 请问listview有什么优点么?grid 还有别的什么优缺点? 比较

多谢


这两个我都不喜欢,msflexgrid感觉比他们方便,还有好多其它的表格控件
[/Quote]

请弄个简单的msflexgrid出来吧 多谢!

看看有多简单?
unsv29mj 2010-03-26
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 king06 的回复:]
VB code
With ListView1
'设置成报表样式
.View = lvwReport
'设置列标题
Call .ColumnHeaders.Add(, , "第1列")
Call .ColumnHeaders.Add(, , "第2列")
'添加列表项
……
[/Quote]

能不能弄个详细点的?


多谢
chuifengde 2010-03-26
  • 打赏
  • 举报
回复
listview可以改变显示形式,象文件夹的详细,列表,大图标,小图标,listview还可以find行,第一列前可加图标和checkbox
dbgrid纯粹就是个表格,很少用,一般用于以前的dao绑定,用它不如datagrid
稍强的用msflexgrid和mshflexgrid,这两个可以配合textbox作小型表格录入用,还可以在cell中单独加图片,详细的可以参照msdn
jhone99 2010-03-26
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 unsv29mj 的回复:]
既然listview这么麻烦 请问listview有什么优点么?grid 还有别的什么优缺点? 比较

多谢
[/Quote]

这两个我都不喜欢,msflexgrid感觉比他们方便,还有好多其它的表格控件
unsv29mj 2010-03-26
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 bestbadgod 的回复:]

引用 6 楼 unsv29mj 的回复:
引用 4 楼 unsv29mj 的回复:

引用 2 楼 bestbadgod 的回复:

listview1.listitem(i).listsubitem(j-1).text=value


编译后 显示 compile error
method or data member not found


我直接 拖个 listvi……
[/Quote]

既然listview这么麻烦 请问listview有什么优点么?grid 还有别的什么优缺点? 比较

多谢
xrongzhen 2010-03-26
  • 打赏
  • 举报
回复
这些都是最最基本的啊 看一下MSDN,试验一下 再不会的网上下几个实例 自己练习一下
倒大霉的上帝 2010-03-25
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 unsv29mj 的回复:]
引用 4 楼 unsv29mj 的回复:

引用 2 楼 bestbadgod 的回复:

listview1.listitem(i).listsubitem(j-1).text=value


编译后 显示 compile error
method or data member not found


我直接 拖个 listview1控件 到 窗体上

然后弄个按钮
……
[/Quote]
你得先加载数据 然后才能用,比如你要修改第3行第4列,那么得这这行这列上加载了数据才行。
bcrun 2010-03-25
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 unsv29mj 的回复:]
引用 4 楼 unsv29mj 的回复:

引用 2 楼 bestbadgod 的回复:

listview1.listitem(i).listsubitem(j-1).text=value


编译后 显示 compile error
method or data member not found


我直接 拖个 listview1控件 到 窗体上

然后弄个按钮
……
[/Quote]

你不能拿listview控件当grid控件用,listview是要一个一个加项目的.就算是flexgrid,也要先设cols,rows这个数目的啊
king06 2010-03-25
  • 打赏
  • 举报
回复
    With ListView1
'设置成报表样式
.View = lvwReport
'设置列标题
Call .ColumnHeaders.Add(, , "第1列")
Call .ColumnHeaders.Add(, , "第2列")
'添加列表项
Call .ListItems.Add(1, "A", "有").ListSubItems.Add(1, "a", "yes")
Call .ListItems.Add(2, "B", "没有")
Call .ListItems.Add(3, "C", "人")
.ListItems(1).Selected = False
'显示列表项
' Debug.Print .ListItems(1).Text
' Debug.Print .ListItems(1).SubItems(1)
.ListItems(1).ListSubItems(1).Text = "yess"
End With
unsv29mj 2010-03-25
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 unsv29mj 的回复:]

引用 2 楼 bestbadgod 的回复:

listview1.listitem(i).listsubitem(j-1).text=value


编译后 显示 compile error
method or data member not found
[/Quote]

我直接 拖个 listview1控件 到 窗体上

然后弄个按钮
Private Sub Command1_Click()
ListView1.ListItem(3).ListSubItem(4).Text = 10
End Sub



编译后 显示 compile error
method or data member not found
king06 2010-03-25
  • 打赏
  • 举报
回复
设置了列表头之后,就直接.ListItems(i).ListSubItems(j).Text ,不用-1
unsv29mj 2010-03-25
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 bestbadgod 的回复:]

listview1.listitem(i).listsubitem(j-1).text=value
[/Quote]

编译后 显示 compile error
method or data member not found
倒大霉的上帝 2010-03-25
  • 打赏
  • 举报
回复
如果J=1的话
直接 listview1.listitem(i).text=value
倒大霉的上帝 2010-03-25
  • 打赏
  • 举报
回复
listview1.listitem(i).listsubitem(j-1).text=value
  • 打赏
  • 举报
回复
listview不会用,用grid吧

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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