Home All Groups Group Topic Archive Search About

Treeview (Eric Moreau)

Author
10 Sep 2006 8:37 PM
Jerry
Hi Eric,

thnks for the help on your site. It's great. In your example you turned the
node grey and checked the color.

If e.Node.BackColor.ToArgb = Color.Gray.ToArgb Then
    e.Cancel = True
    Microsoft.VisualBasic.Beep()
    Return
End If

I turned the font to italic and tried

if e.Node.NodeFont.Italic = True Then
            e.Cancel = True
            Return
End If

I keep getting "Object reference not set to an instance of an object.".
Could you or someone give me the right code?


Thanks,

Jerry

Author
11 Sep 2006 3:52 AM
gene kelley
Show quote Hide quote
On Sun, 10 Sep 2006 22:37:44 +0200, "Jerry" <jerry***@gmx.net> wrote:

>Hi Eric,
>
>thnks for the help on your site. It's great. In your example you turned the
>node grey and checked the color.
>
>If e.Node.BackColor.ToArgb = Color.Gray.ToArgb Then
>    e.Cancel = True
>    Microsoft.VisualBasic.Beep()
>    Return
>End If
>
>I turned the font to italic and tried
>
>if e.Node.NodeFont.Italic = True Then
>            e.Cancel = True
>            Return
>End If
>
>I keep getting "Object reference not set to an instance of an object.".
>Could you or someone give me the right code?
>
>
>Thanks,
>
>Jerry
>

What you are looking for is:
If e.Node.NodeFont.Style = FontStyle.Italic Then

End if

The above is only valid if you specifically assigned a new drawing font to the node, otherwise, the
return NodeFont is Nohting (default) and "NodeFont.Style" will throw an exception.

Gene
Author
11 Sep 2006 2:38 PM
Claes Bergefall
The code is correct, just make sure that e.Node and e.Node.NodeFont have a
value (i.e. not Nothing):

If e.Node IsNot Nothing AndAlso e.Node.NodeFont IsNot Nothing Then
    If e.Node.NodeFont.Italic Then
        e.Cancel = True
        Return
    End If
End If

   /claes

Show quoteHide quote
"Jerry" <jerry***@gmx.net> wrote in message
news:ee1t2o$etu$00$1@news.t-online.com...
> Hi Eric,
>
> thnks for the help on your site. It's great. In your example you turned
> the node grey and checked the color.
>
> If e.Node.BackColor.ToArgb = Color.Gray.ToArgb Then
>    e.Cancel = True
>    Microsoft.VisualBasic.Beep()
>    Return
> End If
>
> I turned the font to italic and tried
>
> if e.Node.NodeFont.Italic = True Then
>            e.Cancel = True
>            Return
> End If
>
> I keep getting "Object reference not set to an instance of an object.".
> Could you or someone give me the right code?
>
>
> Thanks,
>
> Jerry
>