.net - trouble calling a method in form 2 from a button click on form 1, vb.net -
i have program creating time sheet , when saved time sheet loaded clicking button on form 1 data loads form 2 , calls method in form 2 print data form 3. problem after call form2.print()
there no data on form 2 if open still works in data printed form 3. if remove form2.print()
data loaded on form 2 , can click print button , if open form 2 again data still in text boxes. note: ideally send data form 2 , form 3 open button click event on form 1 print()
method on form 2 many things program other printing making easier call instead of replicating in open click. thank in advance help. cheers!
form 1 code
private sub open_click(byval sender system.object, byval e system.eventargs) handles open.click dim xmldoc xmldocument dim nodelist xmlnodelist dim node xmlnode dim objform2 object = form2 xmldoc = new xmldocument() xmldoc.load("c:\time.xml") nodelist = xmldoc.selectnodes("/timesheet/job1") each node in nodelist dim custname = node.childnodes.item(0).innertext form2.txtbxcustname.text = custname dim wo = node.childnodes.item(1).innertext form2.txtbxwonum.text = wo next objform2.print() end sub
`
form 2 code
private sub btnprint_click(byval sender system.object, byval e system.eventargs) handles btnprint.click print() end sub public sub print() form3.labelcustname.text = txtbxcustname.text form3.labelwonum.text = txtbxwonum.text me.close() end sub
no need cast form2
object call print . new instance of form directly call .and every time assining new values text box inside each block . achieve want can many ways instead of texbox
objects show string
object.
in form2 , form3 class add
public property xmldata string 'use own class or other types list controls(textbox,.)whatever want . 'you have inside open click dim form2 new form2()
if want initialize form2 , form3 once , use accross program should add line prevent disposing when closing()
private sub form2_formclosing(sender object, e system.windows.forms.formclosingeventargs) handles me.formclosing me.hide() e.cancel = true end sub form2.xmldata=yourxmldata form2.print() form2.show()'show form2
lemme if helped . if not reedit answer u understand
Comments
Post a Comment