View Full Version : DotNet TreeView: Checkboxes only on top level?
Jon-Huhn 03-07-2008, 01:06 AM Using a DotNet TreeView control, is it possible to have checkboxes present on some levels but not others? Similar to the lightbulb icons in the modifier stack, I'd like to have checkboxes on the top level but not on any nodes below it.
I suppose my second option is to make custom checkboxes using bitmaps if indeed I can't do what I'm wanting with standard DotNet.
|
|
ypuech
03-07-2008, 07:53 AM
You can't do that with standard .NET. But maybe a custom TreeView control doing that could be found on the web.
The bitmap solution should work by tracking the mouse click and its position and display the appropriate bitmap state. You can get a bitmap representing the cheched/unchecked state of a checkbox by creating one dynamically and drawing it to a bitmap using CheckBox.DrawToBitmap():
(
chekbox = dotNetObject "System.Windows.Forms.CheckBox"
-- Just display ChekBox check rectangle
chekbox.Width = 13
chekbox.Height = 13
chekbox.Text = ""
bmp = dotNetObject "System.Drawing.Bitmap" chekbox.Width chekbox.Height
rect = dotNetObject "System.Drawing.Rectangle" 0 0 chekbox.Width chekbox.Height
-- Draw ChechBox unchecked
chekbox.DrawToBitmap bmp rect
bmp.Save "CheckBoxUnchecked.png"
-- Draw ChechBox checked
chekbox.Checked = true
chekbox.DrawToBitmap bmp rect
bmp.Save "CheckBoxChecked.png"
bmp.Dispose()
chekbox.Dispose()
)
Jon-Huhn
03-07-2008, 12:59 PM
ypuech,
Thanks so much for your help. I like your idea about generating the bitmap from the actual dotnet checkbox. Very clever! I can use the code you posted for many other things as well. Thanks!
CGTalk Moderation
03-07-2008, 12:59 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.