Treeview (Eric Moreau)

  • Thread starter Thread starter Jerry
  • Start date Start date
J

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
 
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
 
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
 
Back
Top