c# - Handling data between multiple Forms -


i working on program generates pdf file. before final generation of file, want give user option edit portion of file (the title of graph created). want show in new form when user clicks button export pdf. here outline of trying do...

private void button4_click(object sender, eventargs e) // test pdf code! {     form2 newpdf = new form2(chart3.titles[chart3.titles.indexof("header")].text.tostring().substring(0, chart3.titles[chart3.titles.indexof("header")].text.tostring().length - 4));     newpdf.show();       if (newpdf.selected == true)     {        // create pdf, open save file dialog, etc                  } } 

and here form being opened button click...

public partial class form2 : form {      public bool selected     {         get;         set;     }      public string graphname     {         get;         set;     }       public form2(string filename)     {         initializecomponent();         textbox1.text = filename;         graphname = filename;         selected = false;     }     public void button1_click(object sender, eventargs e)     {         graphname = textbox1.text;         this.selected = true; // after button selected want code written above continue execution, not!     } } 

as of now, when click on button in form2, nothing happens, there communication between 2 forms not understanding!

you should change form2.graphname below

public string graphname {     { return textbox1.text } } 

then change new form2 creation below, test since haven't run through vs, should work :)

private void button4_click(object sender, eventargs e) // test pdf code! {     // why on earth doing .text.tostring()?  it's string...     form2 newpdf = new form2(chart3.titles[chart3.titles.indexof("header")].text.substring(0, chart3.titles[chart3.titles.indexof("header")].text.length - 4));      // show dialog form, wait exit, , set form parent     newpdf.showdialog(this);       if (newpdf.selected == true)     {         // name other form         string filename = newpdf.graphname;         // create pdf, open save file dialog, etc     } } 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -