Here, we took two controls on windows form that are TextBox and Button, named txtInput and btnShow respectively. We have to write C# code to display TextBox’s text in the MessageBox on Button Click.
在这里,我们在Windows窗体上使用了两个控件,分别是TextBox和Button,分别命名为txtInput和btnShow 。 我们必须编写C#代码以在Button Click上的MessageBox中显示TextBox的文本 。
Example:
例:
In the above application, we wrote code on button click event to show text in MessageBox entered in TextBox.
在上面的应用程序中,我们在按钮单击事件上编写了代码,以显示在TextBox中输入的MessageBox中的文本。
private void btnShow_Click(object sender, EventArgs e)
{
MessageBox.Show(textInput.Text);
}
翻译自: https://www.includehelp.com/dot-net/design-an-application-to-display-text-of-textbox-in-messagebox-on-button-click-event.aspx