TreeView CheckBox question

  • Thread starter Thread starter Chung
  • Start date Start date
C

Chung

Can we have a check box to show up on only certain treeNodes? My
knowledge tells me that this can't be done with what VS provides. What
can we do to get around this?

What I want to do is provide a check box for all the child tree nodes
except the root node.

Any suggestions?

Thanks in advance.
 
Hi Chunghu,

Yes, you're right, this isn't supported. One option is to create a custom
treeview control, but by the sounds of your requirements this could be an
overkill. I think I'd experiment with a different UI - maybe don't show
the root node in the tree, but display that same information in a label
above the treeview.

Ben Albahari
.NET Compact Framework
Microsoft

This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
| From: (e-mail address removed) (Chung)
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| Subject: TreeView CheckBox question
| Date: 8 Oct 2003 12:49:19 -0700
| Organization: http://groups.google.com
| Lines: 10
| Message-ID: <[email protected]>
| NNTP-Posting-Host: 207.207.28.210
| Content-Type: text/plain; charset=ISO-8859-1
| Content-Transfer-Encoding: 8bit
| X-Trace: posting.google.com 1065642559 32254 127.0.0.1 (8 Oct 2003
19:49:19 GMT)
| X-Complaints-To: (e-mail address removed)
| NNTP-Posting-Date: Wed, 8 Oct 2003 19:49:19 +0000 (UTC)
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-onlin
e.de!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!sn-xit-03!sn-xit-01!sn-
xit-09!supernews.com!postnews1.google.com!not-for-mail
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.compactframework:35447
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| Can we have a check box to show up on only certain treeNodes? My
| knowledge tells me that this can't be done with what VS provides. What
| can we do to get around this?
|
| What I want to do is provide a check box for all the child tree nodes
| except the root node.
|
| Any suggestions?
|
| Thanks in advance.
|
 
I am working on the same problem. How to create a treview with checkboxes on
some of the nodes but not others. I created my own checkbox images and am
using an ImageList with the treview to show the appropriate checkbox image
in the icon of the node. The problem I am having now is how to determine
when the user clicks on the icon to toggle the checkbox (change the image).
The TreeView doesn't have a click event or even a mousedown event to work
with.

I was able to accomplish this feature in eVB (which had similar limitations)
by using a custom control called MessageCE which would allow subclassing
controls and intercepting windows messages destined for the control. Then
with a few API calls you can take the X,Y coordinates of the click and
determine what node the user clicked and even if they clicked on the icon or
some other portion of the node. I was hoping that .NET would allow me to do
all this without so much difficulty, but so far it is NOT looking good.
Please be sure to post back if you have any luck with this. I am very
interested. Thanks.
 
Funny enough, this is the exact same approach I'm taking. But like
you, I can't fingure out a way to detect the position of the tap.
Plus, what if the user scrolls the treeView, then the X, Y coordinate
wouldn't be helpful either.

Instead of detecting the stylus tap, I would launch a new window to
allow the user to edit the appropriate fields, and use the imagelist
to reflect such changes. It's not a clean solution, but it works for
now... I'll keep looking into this issue and give an update if I
should find anything.
 
Scrolling is not a problem, because once you have the location of the tap
you can use an API call to SendMessageW to get the HitTestInfo. This will
give you all the info you need including where on the node the user clicked
(i.e. the icon, the text, etc) This will give you an hitem handle and there
is a way to determine the node from this. It is complicated, but I have it
working in eVB. In eVB I had to use a native DLL (MessageCE.dll) to get the
initial WM_LBUTTONDOWN message.
 
Back
Top