PantoffelSlippers
asked on
Using groups in the listview control
Hi Experts,
I'm writing a VB.Net 2005 application. I have a tree-view control on my form and a listview control on its right. The listview control has to show all the child nodes of the selected treeview node. That's easy enough, however I'm having some problems formatting the listview control the way I want it.
I'd like to use that lovely group heading (the one with the fading blue line, looks very cool). In order to use groups, I think the listview's view must be set to details which I've done. The heading is displayed.
I've got two problems remaining:
1. The group heading reads "Default". How do I change it? I've tried this without luck:
me.lvwNodeContent.Groups(0 ).Name = ParentNode.Text
2. I don;t want the listview's column header displayed. It looks ugly!! Any way of hiding it?
Thanks
I'm writing a VB.Net 2005 application. I have a tree-view control on my form and a listview control on its right. The listview control has to show all the child nodes of the selected treeview node. That's easy enough, however I'm having some problems formatting the listview control the way I want it.
I'd like to use that lovely group heading (the one with the fading blue line, looks very cool). In order to use groups, I think the listview's view must be set to details which I've done. The heading is displayed.
I've got two problems remaining:
1. The group heading reads "Default". How do I change it? I've tried this without luck:
me.lvwNodeContent.Groups(0
2. I don;t want the listview's column header displayed. It looks ugly!! Any way of hiding it?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Add, I was wrong. You do add the items to the ListView directly, but you also set the item's Group property. Mentioned in the how-to. Don't forget the Application.EnableVisualSt yles method call, either.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Experts!
Let me have a look!
Let me have a look!
ASKER
Thank you experts!
A perfect solution in no time.
Thanks for effort - everyone joined in.
Thanks again!
A perfect solution in no time.
Thanks for effort - everyone joined in.
Thanks again!
ASKER
My final code looks like this:
Private Sub UpdateContent(ByRef ParentNode As TreeNode)
Dim XNode As TreeNode
Dim XItem As ListViewItem
'Prepare the listview
With Me.lvwNodeContent
.Items.Clear()
.Groups.Clear()
.Columns.Clear()
.Columns.Add("", CInt(lvwNodeContent.Width * 0.98), HorizontalAlignment.Left)
.Groups.Add(ParentNode.Tex t, ParentNode.Text)
End With
'Add the nodes
For Each XNode In ParentNode.Nodes
XItem = lvwNodeContent.Items.Add(X Node.Text)
XItem.Tag = XNode.Index
XItem.ImageIndex = XNode.ImageIndex
XItem.Group = lvwNodeContent.Groups(Pare ntNode.Tex t) 'Key
Next
End Sub
Private Sub UpdateContent(ByRef ParentNode As TreeNode)
Dim XNode As TreeNode
Dim XItem As ListViewItem
'Prepare the listview
With Me.lvwNodeContent
.Items.Clear()
.Groups.Clear()
.Columns.Clear()
.Columns.Add("", CInt(lvwNodeContent.Width * 0.98), HorizontalAlignment.Left)
.Groups.Add(ParentNode.Tex
End With
'Add the nodes
For Each XNode In ParentNode.Nodes
XItem = lvwNodeContent.Items.Add(X
XItem.Tag = XNode.Index
XItem.ImageIndex = XNode.ImageIndex
XItem.Group = lvwNodeContent.Groups(Pare
Next
End Sub
ASKER
Thank you experts
You're welcome :)
Your items should be added to the groups, rather than directly to the ListView.