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