C#獲得彈出框的值

pamxy發表於2013-10-16

轉自:http://wenwen.soso.com/z/q185771150.htm

1. 輸入框

 private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.textBox1.Text != "")
                {
                    SecFresh = Convert.ToInt32(this.textBox1.Text.Trim());
                    this.DialogResult = DialogResult.OK;
                }
            }
            catch { }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

 

2.  儲存

            Form1 frmset = new Form1();
            frmset.SecFresh = sr;            
            if (frmset.ShowDialog(this)== DialogResult.OK)
            {
                try
                {
                    this.sr = frmset.SecFresh;
                    CLC.INIClass.IniPathSet(Application.StartupPath + "\\ConfigBJXX.ini");
                    CLC.INIClass.IniWriteValue("配置", "更新頻率", sr.ToString());
                    this.timePeople.Interval = sr * 1000;
                    MessageBox.Show("更改成功", "系統提示");
                }
                catch { MessageBox.Show("更改失敗", "系統提示"); }
            }


相關文章