error for parent form serialport object...
-
hi... In my application... I have declared a SerialPort object in parent form & i am accessing it from a child form but its giving an error in port 'open' method. Can anybody tell me where i am going wrong... Here is sample code for some more information... //In parent form public SerialPort comport = new SerialPort(); child_Form childForm= new child_Form();//this is the child form child_Form .MdiParent = this; comport.PortName = "COM1"; //In child form if(!((ParentForm)this.MdiParent).comport.IsOpen) ((ParentForm)this.MdiParent).comport.Open(); // Getting error on this line ((ParentForm)this.MdiParent).comport.Write("send the text on serial Port"); I am getting intellisense for parent's 'comport' in child form. above two sentence in child are write or wrong...? where i'm doing mistake...? Thanks in adavance, Vinay
-
hi... In my application... I have declared a SerialPort object in parent form & i am accessing it from a child form but its giving an error in port 'open' method. Can anybody tell me where i am going wrong... Here is sample code for some more information... //In parent form public SerialPort comport = new SerialPort(); child_Form childForm= new child_Form();//this is the child form child_Form .MdiParent = this; comport.PortName = "COM1"; //In child form if(!((ParentForm)this.MdiParent).comport.IsOpen) ((ParentForm)this.MdiParent).comport.Open(); // Getting error on this line ((ParentForm)this.MdiParent).comport.Write("send the text on serial Port"); I am getting intellisense for parent's 'comport' in child form. above two sentence in child are write or wrong...? where i'm doing mistake...? Thanks in adavance, Vinay