c# - Linking two forms together -
i wondering if possible persay 'link' 2 winforms in c#. in way can call variables like: applicationproperties.applicationport.baudrate
instead of having make instance want call? similar vb.net. if point me in right direction appriciated.
i have 2 forms(mainbox) , (applicationproperties). have both form accessable eachother. in way similar vb.net.
ex:
in form 1 have serial port (applicationport), , writing values .xml file.
public void saveapplicationproperties() { try { //createnode(everything being referenced. put text boxes, , drop down boxes here. xmltextwriter writer = new xmltextwriter(@"c:\fortesenderv2.0\properties.xml", system.text.encoding.utf8); writer.writestartdocument(true); //making code indeted 2 characters. writer.formatting = formatting.indented; writer.indentation = 2; //making start element "table". writer.writestartelement("forte_data_gatherer_application"); //calling rst of .xml file write. createnode(applicationport.portname, applicationport.baudrate.tostring(), applicationport.databits.tostring(), applicationport.parity.tostring(), applicationport.stopbits.tostring(), applicationport.handshake.tostring(), writer); writer.writeendelement(); writer.writeenddocument(); writer.close(); messagebox.show(applicationport.portname); messagebox.show(applicationport.baudrate.tostring()); } catch (exception ex) { messagebox.show("writing .xml file failure: " + ex.message); } }
now able call serial port form 2 without having make instance. have working instance finding tedious creat instance every serial port, text box, or tool want use in form2. ther way can call them in vb.net?
instead of having make instance want call
if instance method have create instance of form if think can make method static can call way want. e.g
public partial class form1 : form { new form2().instancemethod(); //call instance form2.staticmethod(); // call without creating instane } public partial class form2 : form { public void instancemethod() {} public static void staticmethod() {} }
Comments
Post a Comment