Noob question...

  • Thread starter Thread starter rhaazy
  • Start date Start date
R

rhaazy

I have a windows form that loads and displays a dialog box...

The user inputs a few strings into this dialog box.

I want to be able to store these strings and make them accessible to
the scope of the entire application.

So my question is how do I make reference to a string that was
inititilized somewhere else?
 
rhaazy, the easy way is to...

Create some public properties that return the textbox.text of the
dialog's textboxes, and then retrieve the values in your main form just
after the line that shows your dialogue - which is where your main form
will start executing again after the dialog is closed.

ie

class MainForm
{
private string m_sStringFromDialog;

private void ShowMyDialogue()
{
//create a new dialog object called 'frm'
....
//show the dialogue
frm.ShowDialog();
m_sStringFromDialog = frm.MyString
}
....
}

class OtherDialog
{
public string _Text1 { get { return TextBox1.Text; } }
....
}
 
pigeonrandle said:
rhaazy, the easy way is to...

Create some public properties that return the textbox.text of the
dialog's textboxes, and then retrieve the values in your main form just
after the line that shows your dialogue - which is where your main form
will start executing again after the dialog is closed.

ie

class MainForm
{
private string m_sStringFromDialog;

private void ShowMyDialogue()
{
//create a new dialog object called 'frm'
...
//show the dialogue
frm.ShowDialog();
m_sStringFromDialog = frm.MyString
}
...
}

class OtherDialog
{
public string _Text1 { get { return TextBox1.Text; } }
...
}

I think that that last bit should have been:

class OtherDialog
{
public string MyString { get { return TextBox1.Text; } }
....
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top