Re: TreeView Nonsense
- From: "Jon Slaughter" <Jon_Slaughter@xxxxxxxxxxx>
- Date: Fri, 13 Oct 2006 16:11:26 -0500
"PS" <ecneserpegats@xxxxxxxxxxx> wrote in message
news:%234WnzOw7GHA.3736@xxxxxxxxxxxxxxxxxxxxxxx
"Jon Slaughter" <Jon_Slaughter@xxxxxxxxxxx> wrote in message
news:12ivrq99qat58c0@xxxxxxxxxxxxxxxxxxxxx
"PS" <ecneserpegats@xxxxxxxxxxx> wrote in message
news:eoz30zv7GHA.4568@xxxxxxxxxxxxxxxxxxxxxxx
"Jon Slaughter" <Jon_Slaughter@xxxxxxxxxxx> wrote in message
news:12iu4eb5angjr62@xxxxxxxxxxxxxxxxxxxxx
I'm trying to override the default paiting of a treeview but I get bad
results:
My code(well, atleast this is the most simple that reproduces the
result) is this
private void TVDrawNode(Object sender, DrawTreeNodeEventArgs e)
{
e.Graphics.DrawString(e.Node.Text, e.Node.TreeView.Font, Brushes.Black,
e.Bounds.Left, e.Bounds.Top);
}
Does this help?
When using OwnerDrawAll, however, the DrawTreeNodeEventArgs.Bounds
property encompasses the entire width of the TreeView. In this case, you
can access the hit test region by getting the DrawTreeNodeEventArgs.Node
value and accessing its TreeNode.Bounds property.
I've tried the TreeNode.Bounds on the e.Nodes and its the same thing
except the indention changes.
i.e., using e.Node.Bounds instead of e.Bounds. Same result except
indentation is alreadly done for me. I think that is what you are getting
at though. Remember, it works fine once I hide the window and bring it
back up
It seems that some hidden nodes upon scrolling or expanding into view
initially have e.Node.Bounds equal to 0 for X, Y, Height and Width. You
should check that these values are not zero before drawing the node.
Yes, they are sometimes zero but why? Why would the draw routine be called
like that? It would be nice if there was some information on the behavior of
these controls. MSDN does a piss-poor job of describing the workings of
them.
I suppose what might be happening is that the very first time the control is
displayed the TreeView control is not setting up the Bounds properly or
something like that? I really have no idea though ;/ I will try what you
sugggest and see if that fixes(it definately will but might break something
else).
Thanks,
Jon
.
- Follow-Ups:
- Re: TreeView Nonsense
- From: PS
- Re: TreeView Nonsense
- References:
- TreeView Nonsense
- From: Jon Slaughter
- Re: TreeView Nonsense
- From: PS
- Re: TreeView Nonsense
- From: Jon Slaughter
- Re: TreeView Nonsense
- From: PS
- TreeView Nonsense
- Prev by Date: C# destructor and finalizer - guarentees?
- Next by Date: Re: ThreadAbortException occurs when the child thread is in catch block{}
- Previous by thread: Re: TreeView Nonsense
- Next by thread: Re: TreeView Nonsense
- Index(es):
Relevant Pages
|