У меня есть форма с некоторыми элементами в ней. Я хочу получить доступ к данным из этой формы в моей основной. Я попытался сделать следующее:Доступ к свойствам из другой формы
private void button1_Click(object sender, EventArgs e)
{
Properties.Settings.Default.emailServer = textBox1.Text;
Properties.Settings.Default.emailServerPort = (int)numericUpDown1.Value;
Properties.Settings.Default.emailServerSsl = (radioButton1.Checked == true) ? true : false;
Properties.Settings.Default.Save();
this.Close();
}
я могу загрузить его прекрасно в существующем виде, используя этот код:
private void EmailSettings_Load(object sender, EventArgs e)
{
textBox1.Text = Properties.Settings.Default.emailServer;
numericUpDown1.Value = Properties.Settings.Default.emailServerPort;
if (Properties.Settings.Default.emailServerSsl == true)
{
radioButton1.Checked = true;
}
else
{
radioButton1.Checked = false;
}
}
ОДНАКО, мой вопрос заключается в том, что я не могу получить доступ к Properties
из моей главной формы , Поэтому я до сих пор не могу получить доступ к данным из этой формы. Как я могу получить доступ к данным либо из свойств в моей основной форме, либо из другой формы?
Посмотрите здесь: http://stackoverflow.com/questions/35897399/access-variables-between-cs-files-in-wpf-c-sharp/35897626#35897626 ... это именно ваша проблема. – Fruchtzwerg