Click here to Skip to main content
15,886,030 members
Please Sign up or sign in to vote.
1.33/5 (2 votes)
See more:
Hi I am trying to set a tooltip to a textbox progamatically,but i am keep getting the error:

An exception of type 'System.NullReferenceException' occurred in e-Learning.exe but was not handled in user code
The error :Object reference not set to an instance of an object.

the code:
C#
ToolTip tt = new ToolTip();
            tt.Content="Introduceti adresa URL a videocipului";
             loca.ToolTip = tt;


any ideas how can i set the tooltip ?
I am sorry if i wasn't clearly enough.
P.S "loca" is the name of the textbox
Posted
Updated 15-May-15 2:00am
v3
Comments
Herman<T>.Instance 15-May-15 8:01am    
who is null? Did you debug that?
SGS97 15-May-15 8:06am    
loca is null
Matt T Heffron 15-May-15 20:18pm    
So use "Improve question" and show us how you set the value of loca.
That's pretty clearly where this problem lies.

Why don't you set the tool tip in XAML?
Refer this http://wpftutorial.net/ToolTip.html[^]
 
Share this answer
 
Comments
SGS97 15-May-15 8:57am    
well, i need to change the tooltip text depending on the selection the users make,
the problem is that loca("name of the textbox") loca value is null
Okay
if (loca != null)
{
ToolTip tt = new ToolTip();
tt.Content="Introduceti adresa URL a videocipului";
loca.ToolTip = tt;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900