读书人

InputBox中怎么正确传递字符串

发布时间: 2013-10-03 17:28:15 作者: rapoo

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 赋值的语句

读书人网 >C#

热点推荐