Click here to Skip to main content
15,746,302 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
this is my code
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
           SolidColorBrush myBrush = new SolidColorBrush(Colors.Red);

           StackPanel SP = new StackPanel();
           SP.Height = 50;
           SP.Width = 300;
           SP.Background = myBrush;

           TextBlock TB = new TextBlock();
           TB.Width = 30;
           TB.Height = 30;
         TB.Text = "World Of Waracrft";

           //wow search
         if (Sois.Properties.Settings.Default.sel == 2)
             if (tb1.Text == "wow")




this is my error
Object reference not set to an instance of an object.

and the error is at


1 solution

This is because sp1 == null.

This question is abuse and spam at the same time; and this is just rude to ask a question about an error related to some variable and not show its declaration and initialization. I don't even mention that this code should be run under debugger.

Share this answer
[no name] 30-Oct-11 0:43am    
so how do i fiz it??
Espen Harlinn 30-Oct-11 8:45am    
Assuming sp1 is a StackPanel you need to create it - perhaps in your xaml file
Sergey Alexandrovich Kryukov 30-Oct-11 19:57pm    
What part of my answer was not clear?
[no name] 1-Nov-11 22:14pm    
all of it!, I didn't underatnd any of it :( , please refrace it
Espen Harlinn 30-Oct-11 8:43am    
Good points

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