G
gooseneckster
Hi,
Does anyone have an idea on how to display two images on a treeview's
treenode? (.Net v1.1)
At the moment I have made a TreeViewEx component that inherits from
TreeView.
I'm overriding the OnPaint and there I call method below with
PaintEventArgs.Graphics and my root TreeNode:
private void SetImagePositions(Graphics g, TreeNode node)
{
if (node.IsVisible)
{
node.ImageIndex = 0; // for test, assumes an ImageList with two
images is chosen for the treeview
node.SelectedImageIndex = 0;
PictureBox statusImage = new PictureBox();
statusImage.Image = ImageList.Images[1]; // for test, assumes an
ImageList with two images is chosen for the treeview
statusImage.Location = new Point(node.Bounds.Left-22,
node.Bounds.Top);
statusImage.Size = new Size(16, 16);
g.DrawImage(statusImage.Image, statusImage.Location);
foreach(TreeNode childNode in node.Nodes)
SetImagePositions(g, childNode);
}
}
This however works badly, as if this triggers some other event which
makes the treeview redraw some of it's nodes again on top of the extra
image...
Does anyone have any idea, please help...
Thanks alot in advance,
Cheers
Jag
Does anyone have an idea on how to display two images on a treeview's
treenode? (.Net v1.1)
At the moment I have made a TreeViewEx component that inherits from
TreeView.
I'm overriding the OnPaint and there I call method below with
PaintEventArgs.Graphics and my root TreeNode:
private void SetImagePositions(Graphics g, TreeNode node)
{
if (node.IsVisible)
{
node.ImageIndex = 0; // for test, assumes an ImageList with two
images is chosen for the treeview
node.SelectedImageIndex = 0;
PictureBox statusImage = new PictureBox();
statusImage.Image = ImageList.Images[1]; // for test, assumes an
ImageList with two images is chosen for the treeview
statusImage.Location = new Point(node.Bounds.Left-22,
node.Bounds.Top);
statusImage.Size = new Size(16, 16);
g.DrawImage(statusImage.Image, statusImage.Location);
foreach(TreeNode childNode in node.Nodes)
SetImagePositions(g, childNode);
}
}
This however works badly, as if this triggers some other event which
makes the treeview redraw some of it's nodes again on top of the extra
image...
Does anyone have any idea, please help...
Thanks alot in advance,
Cheers
Jag