listview的子项subitem如何添加checkbox?

lilysunny13 2004-06-11 03:40:58
我想实现如listview每个item可以有checkbox的功能,只是checkbox在每个item的子项中!

另外一个问题,listview可不可以不叫columsHeader呢?我就只想加数据,不想添加columsHeader!或者说listview的columsHeader可不可以添加图片呢?

多谢高手指点一二啊!
...全文
970 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
lilysunny13 2004-07-02
  • 打赏
  • 举报
回复
to: lxcc(虫子)
看看先,多谢!
lxcc 2004-07-01
  • 打赏
  • 举报
回复
http://dev.csdn.net/develop/article/21/21801.shtm
lxcc 2004-07-01
  • 打赏
  • 举报
回复
自定义ListView控件
lilysunny13 2004-07-01
  • 打赏
  • 举报
回复
to:webmasterss(天涯解语花)

谢谢,控件我下了,但是好像这个控件是通过设columns的数量,然后在一列排不下的时候才排到第二列哦!不知道是不是这样用呢?好象跟我的目的有点出入,不过还是很感谢了!
webmasterss 2004-06-30
  • 打赏
  • 举报
回复
到这里下载chklistbox控件
http://www.zjonline.com.cn/vbbible/software/program/download/control/chklst.zip
安装后在项目,添加引用中引用安装目录下的那个OCX就可以了!
lilysunny13 2004-06-30
  • 打赏
  • 举报
回复
to:billfancy(bill)
不好意思,你的代码也并没有向子项里也就是你代码中写1、2、3的地方加上checkbox呀!我的目的就是在你代码运行结果的1、2、3的内容前面也加上checkbox,而不是只有item1、item2的前面加上checkbox!帮我再看看吧,多谢了!
billfancy 2004-06-23
  • 打赏
  • 举报
回复
照着做,肯定可以
Private Sub form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
CreateMyListView
End Sub

Private Sub CreateMyListView()
' Create a new ListView control.
Dim listView1 As 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.
Dim item1 As 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")
Dim item2 As New ListViewItem("item2", 1)
item2.SubItems.Add("4")
item2.SubItems.Add("5")
item2.SubItems.Add("6")
Dim item3 As 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)

'Add the items to the ListView.
listView1.Items.AddRange(New ListViewItem() {item1, item2, item3})

' Create two ImageList objects.
Dim imageListSmall As New ImageList()
Dim imageListLarge As New ImageList()

' Initialize the ImageList objects with bitmaps.
imageListSmall.Images.Add(Bitmap.FromFile("C:\1.bmp"))
imageListSmall.Images.Add(Bitmap.FromFile("C:\2.bmp"))
imageListLarge.Images.Add(Bitmap.FromFile("C:\3.bmp"))
imageListLarge.Images.Add(Bitmap.FromFile("C:\4.bmp"))

'Assign the ImageList objects to the ListView.
listView1.LargeImageList = imageListLarge
listView1.SmallImageList = imageListSmall

' Add the ListView to the control collection.
Me.Controls.Add(listView1)
End Sub 'CreateMyListView
lilysunny13 2004-06-22
  • 打赏
  • 举报
回复
没有解答吗?自己顶一下,高手帮忙!
lilysunny13 2004-06-17
  • 打赏
  • 举报
回复
我就是想实现listview每个item可以有checkbox的功能,就是checkbox在每个item的子项中,而不只是一个item一个checkbox,咋弄?
lwjlwj 2004-06-15
  • 打赏
  • 举报
回复
checkListBox没有listview功能强大,看帮助
lilysunny13 2004-06-15
  • 打赏
  • 举报
回复
好想不能满足我的需要,有其他办法吗?高手帮忙!
lilysunny13 2004-06-11
  • 打赏
  • 举报
回复
哎呀,我都没有注意有这样的控件,真是弱啊!多谢多谢!

再补充问一句,checkListBox里子项可以是写内容也可以用checkbox的吧!~

还有columsHeader可不可以添加图片呢?
tenglong2004 2004-06-11
  • 打赏
  • 举报
回复
用checkListBox不行吗?

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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