المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : why System.NullReferenceException occurred?



C# Programming
02-23-2013, 08:00 PM
Hi,

I am using the following code to activate existing MDI child and ******* the grid at the same time. It was working fine until today but suddenly I am getting:\

System.NullReferenceException occurred
Message=Object reference not set to an instance of an object.
Source=Cure
StackTrace:
at cure_hospital_management.frmMain.repositoryItemFindFile_KeyDown(Object sender, KeyEventArgs e) in C:\Users\DELL USER\Documents\Visual Studio 2010\Projects\Cure\Cure\main_form.cs:line 1718
InnerException:


here is the code:

if (e.KeyCode == Keys.Enter && (sender as TextEdit).Text.Trim() != ""){ this.Cursor = Cursors.WaitCursor; is_form_exists = false; foreach (Form search_resul_form in this.MdiChildren) { frmSearchResult search_form = search_resul_form as frmSearchResult; if ((string)search_form.Tag == "BROWSE_PATIENTS") { // search_form.Activated(null, null); search_form.find_what = "FILE"; search_form.find_text1 = (sender as TextEdit).Text.Trim(); search_form.find_text2 = null; search_form.browse_result(); search_form.Activate(); is_form_exists = true; break; } } if (is_form_exists == false) { frmSearchResult SearchResultForm = new frmSearchResult(public_var); SearchResultForm.Tag = "BROWSE_PATIENTS"; SearchResultForm.MdiParent = this; SearchResultForm.Dock = DockStyle.Fill; SearchResultForm.find_what = "FILE"; SearchResultForm.find_text1 = (sender as TextEdit).Text.Trim(); SearchResultForm.find_text2 = null; SearchResultForm.Show(); } (sender as TextEdit).Text = ""; this.Cursor = Cursors.Default;}

Technology News @ www.JassimRahma.com