When I click a button, I want a box to popup on the screen and display a simple message. Nothing fancy really. How would I do that?
System.Windows.Forms.MessageBox.Show("My message here");
确保System.Windows.Forms
程序集引用了您的项目。
只需键入mbox
然后点击选项卡,它将为您提供一个魔术快捷方式来填充消息框。
In Visual Studio 2015 (community edition), System.Windows.Forms
is not available and hence we can't use MessageBox.Show("text")
.
Use this Instead:
var Msg = new MessageDialog("Some String here", "Title of Message Box");
await Msg.ShowAsync();
Note: Your function must be defined async to use above await Msg.ShowAsync()
.
Try this:
string text = "My text that I want to display";
MessageBox.Show(text);
Nothing fancy? Try MessageBox
Why not make use of a tooltip?
private void ShowToolTip(object sender, string message)
{
new ToolTip().Show(message, this, Cursor.Position.X - this.Location.X, Cursor.Position.Y - this.Location.Y, 1000);
}
The code above will show message for 1000 milliseconds (1 second) where you clicked.
To call it, you can use the following in your button click event:
ShowToolTip("Hello World");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.