[Closed] DotNet TreeView: Checkboxes only on top level?
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.
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()
)
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!