|
-
Aug 13th, 2002, 06:58 AM
#1
Thread Starter
New Member
Tree view checkboxes
How can I cause a TreeView to have checkboxes only on the low-level nodes only (Only nodes with not children will have a checkbox
Thanks
-
Aug 19th, 2002, 07:34 PM
#2
Member
You have to do some hard work, Dude! Try adding images of Unchecked Checkbox to desired nodes, then in changing the active node event check to see if Count property of Nodes property is zero. If it is, so this is your node, change image to other state - if it's checked change to unchecked and vice versa.
-
Sep 5th, 2002, 03:47 AM
#3
New Member
Treeview checkboxes
Hi,
I could do it with vb6 with the following code:
Public Sub UnckeckNode(oTreeView As TreeView)
' Déclaration des variables
Dim lngItem As Long
lngItem = TreeView_GetSelection(oTreeView.hwnd)
If lngItem Then
Call SetTVItemStateImage(oTreeView.hwnd, lngItem)
End If
End Sub
' Retrieves the currently selected item.
' Returns the handle to the item if successful or 0 otherwise.
Private Function TreeView_GetSelection(hwnd As Long) As Long
TreeView_GetSelection = TreeView_GetNextItem(hwnd, 0, TVGN_CARET)
End Function
Private Function TreeView_GetNextItem(hwnd As Long, lngItem As Long, flag As Long) As Long
TreeView_GetNextItem = SendMessage(hwnd, TVM_GETNEXTITEM, ByVal flag, ByVal lngItem)
End Function
' Sets the index of the specified treeview item's state image.
' hwndTV - treeview's window handle
' lngItem - item's handle whose checkbox state is to be to set
' iState - value of the state image index
' Returns True if successful, returns False otherwise.
Private Function SetTVItemStateImage(hwndTV As Long, _
lngItem As Long) As Boolean
Dim Tvi As TVITEM
Tvi.mask = TVIF_HANDLE Or TVIF_STATE
Tvi.lngItem = lngItem
Tvi.stateMask = TVIS_STATEIMAGEMASK
Tvi.state = 0
SetTVItemStateImage = TreeView_SetItem(hwndTV, Tvi)
End Function
' Sets some or all of a tree-view item's attributes.
' Old docs say returns zero if successful or - 1 otherwise.
' New docs say returns TRUE if successful, or FALSE otherwise
Private Function TreeView_SetItem(hwnd As Long, pitem As TVITEM) As Boolean
TreeView_SetItem = SendMessage(hwnd, TVM_SETITEM, 0, pitem)
End Function
But it doesn't work with vb.net. I don't know why ?
Any Idea?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|