J
John
I have overridden the default DrawNode (OwnerDrawText mode) to allow me to
draw an extra icon at the front of the text block, while still using the
built-in icon list for another icon. The problem I am having is that when a
node is selected it snips the text to the length of the text minus the
length of the extra icon.
Is there a way to redefine the selection box size for each node?
The DrawNode code is as follows :
private void tvParts_DrawNode(object sender, DrawTreeNodeEventArgs e)
{
Brush fontbrush;
Icon ic;
Font font;
if (ilItemTypeIcons.Images.ContainsKey((e.Node as
itemTreeNode).itemtype_name))
ic = Icon.FromHandle(((Bitmap)ilItemTypeIcons.Images[(e.Node as
itemTreeNode).itemtype_name]).GetHicon());
else
ic =
Icon.FromHandle(((Bitmap)ilItemTypeIcons.Images["Default"]).GetHicon());
if ((e.State & TreeNodeStates.Selected) == TreeNodeStates.Selected)
fontbrush = System.Drawing.Brushes.White;
else
fontbrush = System.Drawing.Brushes.Black;
font = e.Node.NodeFont;
if (font == null)
font = e.Node.TreeView.Font;
e.Graphics.DrawIcon(ic, e.Bounds.X, e.Bounds.Y);
e.Graphics.DrawString(e.Node.Text, font, fontbrush, ic.Width +
e.Bounds.X, e.Bounds.Y);
}
draw an extra icon at the front of the text block, while still using the
built-in icon list for another icon. The problem I am having is that when a
node is selected it snips the text to the length of the text minus the
length of the extra icon.
Is there a way to redefine the selection box size for each node?
The DrawNode code is as follows :
private void tvParts_DrawNode(object sender, DrawTreeNodeEventArgs e)
{
Brush fontbrush;
Icon ic;
Font font;
if (ilItemTypeIcons.Images.ContainsKey((e.Node as
itemTreeNode).itemtype_name))
ic = Icon.FromHandle(((Bitmap)ilItemTypeIcons.Images[(e.Node as
itemTreeNode).itemtype_name]).GetHicon());
else
ic =
Icon.FromHandle(((Bitmap)ilItemTypeIcons.Images["Default"]).GetHicon());
if ((e.State & TreeNodeStates.Selected) == TreeNodeStates.Selected)
fontbrush = System.Drawing.Brushes.White;
else
fontbrush = System.Drawing.Brushes.Black;
font = e.Node.NodeFont;
if (font == null)
font = e.Node.TreeView.Font;
e.Graphics.DrawIcon(ic, e.Bounds.X, e.Bounds.Y);
e.Graphics.DrawString(e.Node.Text, font, fontbrush, ic.Width +
e.Bounds.X, e.Bounds.Y);
}