disabling a textbox at intialization in wpf/C#
-
I'm stumped I have two programs. I'm using the same code in both. It works in one and not in the other. Anybody have any idea what could be causing this? error: System.NullReferenceException: 'Object reference not set to an instance of an object.' tbQ2 was null. code:
private void Btn1_Checked(object sender, RoutedEventArgs e)
{Qtype = "LIKE"; Qpre = " '"; Qpost = "%'"; tbQ2.IsEnabled = false; }
THE XAML code for the wpf is.
And:
-
I'm stumped I have two programs. I'm using the same code in both. It works in one and not in the other. Anybody have any idea what could be causing this? error: System.NullReferenceException: 'Object reference not set to an instance of an object.' tbQ2 was null. code:
private void Btn1_Checked(object sender, RoutedEventArgs e)
{Qtype = "LIKE"; Qpre = " '"; Qpost = "%'"; tbQ2.IsEnabled = false; }
THE XAML code for the wpf is.
And:
jhoga wrote:
Object reference not set to an instance of an object...
... is one of the most common questions asked here. It merely means that you are using a variable reference that has not been initialised, either through omission or error. The only way to track it down is by using the debugger to examine all references at the point of failure. In your case the offending variable is
tbQ2
, but we cannot guess where it should have been setup, or what other code may have affected it. -
jhoga wrote:
Object reference not set to an instance of an object...
... is one of the most common questions asked here. It merely means that you are using a variable reference that has not been initialised, either through omission or error. The only way to track it down is by using the debugger to examine all references at the point of failure. In your case the offending variable is
tbQ2
, but we cannot guess where it should have been setup, or what other code may have affected it.I guess I should have been more detailed in explaining the issue. The code in the two programs are almost identical. I have used this report writer wpf window many times and never had this issue. The xaml code for the checkbox is apparently setting the text box before it is getting initialized in wpf. "OOPs" I think I might have just answered my on question. I hate when that happens. :)
-
I guess I should have been more detailed in explaining the issue. The code in the two programs are almost identical. I have used this report writer wpf window many times and never had this issue. The xaml code for the checkbox is apparently setting the text box before it is getting initialized in wpf. "OOPs" I think I might have just answered my on question. I hate when that happens. :)