Hi,
Unless you have explicity set the ContextMenu property of the textBox2
object, this property is null, in which case you will get the exception
you are getting. Even though the standard windows Edit control has a context
menu it is not the represented in the .NET TextBox class by the ContextMenu
property.
Hope this helps
--
Chris Taylor
http://dotnetjunkies.com/weblog/chris.taylor
"Abubakar" <em**********@yahoo.com> wrote in message
news:ud**************@TK2MSFTNGP10.phx.gbl...
HI all,
working in the vs.net 2k5 beta 2, I write the following code which gives
me an exception:
ContextMenu textboxmenu = textBox2.ContextMenu;
MenuItem menuitem = new MenuItem("hello");
textboxmenu.MenuItems.Add(0,menuitem);
its gives me an exception: "Object reference not set to an instance of an
object.". I understand this msg but its not so, cuz the variable
"menuitem" is properly intantiated and pointing to an object.
Regards,
Abubakar.