Re: TreeView Nonsense

Tech-Archive recommends: Fix windows errors by optimizing your registry




"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


.



Relevant Pages

  • Re: Quest for the simplest zero voltage switching
    ... a single pot that I could adjust from zero to one hundred percent duty ... cycle input to a zero voltage switching controller chip. ... controller chip would then control the Triac swiching the load. ... As the zero cross switch only switched on zero ...
    (sci.electronics.design)
  • Re: Quest for the simplest zero voltage switching
    ... cycle input to a zero voltage switching controller chip. ... controller chip would then control the Triac swiching the load. ... As the zero cross switch only switched on zero ... need to use one comparitor to detect the zero crossing. ...
    (sci.electronics.design)
  • RE: Calculation at subforms
    ... Two things control what happens when the Enter key is pressed. ... show the overall donation amount received by each donor. ... You could get round this by using the Nz function to return a zero for a ... donors, and I'll make it in the way u've suggested. ...
    (microsoft.public.access.gettingstarted)
  • Re: Quest for the simplest zero voltage switching
    ... a single pot that I could adjust from zero to one hundred percent duty ... cycle input to a zero voltage switching controller chip. ... controller chip would then control the Triac swiching the load. ... As the zero cross switch only switched on zero ...
    (sci.electronics.design)
  • Re: Visible or Invisible Code
    ... You said that you did put a breakpoint on the code so that it stops on the ... > BE A NUMBER) Is it a text-formatted control? ... >> it being not exactly zero instead of greater than zero? ...
    (microsoft.public.access.forms)