日期:2014-05-17  浏览次数:20880 次

InputBox中如何正确传递字符串
现有代码如下所示,现在的问题是,当传递了一个字符串给InputBox,用户点击OK之后那个ref string的值并没有变化,请问如何才能正确地返回用户输入的字符串?
    public partial class InputBox : Form
    {
        private string m_input;

        public InputBox(string title, string description, ref string input)
        {
            InitializeComponent();

            this.Text = title;
            this.label.Text = description;
            this.btnOK.Enabled = false;
            m_input = input;
        }

        private void textBox_TextChanged(object sender, EventArgs e)
        {
            btnOK.Enabled = (textBox.Text != "");
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            m_input = textBox.Text;
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }
    }
InputBox 传递 字符串

------解决方案--------------------
没有看到对 input 赋值的语句