473,396 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

TreeViewEx

Trying to extend TreeView \ TreeNode class in .NET 2.0 but need some
advice.

In the above code I'm able to draw the TreeNodeEx text in any font \
color \ size I want and add an image. However, I'd also like to add an
checkbox for each TreeNodeEx added to TreeViewEx but I have no clue
howto draw it in the Draw method (or if thats the approperiate place to
do it). Using ControlPaint.DrawCheckbox is not really an option as far
as I can see (does not contain any functionality only an drawing - cant
check \ uncheck it).

Appreciate any help.

public class TreeViewEx : System.Windows.Forms.TreeView
{
ImageList ImgList;
public TreeViewEx()
{
ImgList = new ImageList();
ImgList.TransparentColor = Color.FromArgb(255, 0, 255);
ImgList.Images.Add(Bitmap.FromFile("C:\\Delete.bmp "));
this.DrawMode = TreeViewDrawMode.OwnerDrawAll;
this.DrawNode += new DrawTreeNodeEventHandler(Draw);
}

public void Draw(Object sender, DrawTreeNodeEventArgs e)
{
TreeNodeEx Node = (TreeNodeEx)e.Node;
Font f;
if (Node.bEnabled)
{
f = new Font("Arial", 12, FontStyle.Italic,
GraphicsUnit.Pixel);
}
else
{
f = new Font("Arial", 12, FontStyle.Regular,
GraphicsUnit.Pixel);
}

e.Graphics.DrawString("Node", f, new SolidBrush(Color.Red),
e.Bounds.Left, e.Bounds.Top);
e.Graphics.DrawImage(ImgList.Images[0], e.Bounds.Left + 50,
e.Bounds.Top);
Node.chkBox.Location = new System.Drawing.Point(e.Bounds.X,
e.Bounds.Y);
Node.chkBox.Show();
}
}

public class TreeNodeEx : System.Windows.Forms.TreeNode
{
public TreeNodeEx(bool enabled) : base()
{
bEnabled = enabled;
chkBox = new CheckBox();
chkBox.Size = new System.Drawing.Size(50, 50);
chkBox.Name = "_test_";
chkBox.Text = "_test_";
chkBox.Visible = true;
chkBox.Enabled = true;
}
public bool bEnabled = false;
public CheckBox chkBox = null;
}

Dec 12 '06 #1
0 1805

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jay Allard | last post by:
Greetings I'm using C# in VS.Net 2002. Whenever I need a page PRE_RENDER event, I add it manually. That involves going into the "do not touch section" to add the handler. This is probably...
3
by: Ed Sutton | last post by:
I need to do a custom sort on a TreeView. I have various object types associated with the TreeNode Tag property. I want to sort objects of the same type at the top of the list, other objects at...
1
by: Trevor | last post by:
How can I recursively loop through _every_ TreeNode in a TreeView using C#? The CheckBoxes property enables checkboxes for all TreeNodes. I only want checkboxes on TreeNodes that have 0 child...
8
by: Brian | last post by:
I have a vb.net application which runs fine when installed locally on a user machine but when the application is run from a network drive a security exception error occurs. I've set the intranet...
1
by: pmcguire | last post by:
OK. My treeview still has a tier with too many nodes (ca. 20,000), but it's the best I can do. Now it only populates that tier in the (unlikely) event that a user tries to expand that tier's parent...
5
by: Boni | last post by:
Dear all, is it possible to implement a tree node so that double click on the tree node does some operation and double click on "+" of this tree node only expands tree without doing this...
11
by: Mano | last post by:
When settiing a TreeNode to bold the text label of that node is clipped. As describedin in the Bug Rebort FDBK16963 I set the underliying TreeView Fond to be bold. Now I have the strange...
3
by: sureshsmani | last post by:
In the tree view, if the size of the text is longer than the size of the control and the mouse is hovered on a item, the item is displayed in full with a yellow highlight. Is is possible to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.