Hello:
I have the floowing code many many times in my code. Is there a way to code it into 1 or 2 lines?
string NYIMessage = "New";
FormNYI FormNYI = new FormNYI(); // Form Not Yet Implemented Dialog
FormNYI.ShowDialog(ref NYIMessage);
Loading

Karan Patel120 reputationPosted Feb 20, 2010, 6:13 PM EST
private void button1_Click(object sender, EventArgs e)
{
Form1 f1 = new Form1("world");
f1.ShowDialog();
}
// in child form
public partial class Form1 : Form
{
public string Msg ;
public Form1()
{
InitializeComponent();
}
public Form1(string s)
{
InitializeComponent();
Msg = s;
// now you can use Msg anywhere you required.
button1.Text = Msg;
}
}
Sam HobbsRank #107 · 20.5K reputationPosted Feb 20, 2010, 7:49 PM EST
Sam HobbsRank #107 · 20.5K reputationPosted Feb 20, 2010, 7:53 PM EST
GustavoRank #1,990 · 732 reputationPosted Feb 21, 2010, 2:27 AM EST
Thanks, I used both of you suggestions.
Sam: I used your line in the MDI Parent.
Karan: I used your line in the MDI Child.
I am Super Newbie and you guys/gals on this forum are helping me so much.
Thanks
Shaik Ali99 reputationPosted Feb 23, 2010, 7:24 AM EST
public static string NYIMessage="New" in one of the class (Assume declared in MyParentClass) then u can simply access from anywhere as MyParentClass.NYIMessage.
Try it out :)