如何创建带有按钮的消息框? [英] How do I create a message box with buttons?

查看:107
本文介绍了如何创建带有按钮的消息框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作Windows窗体,该窗体允许人们从不同类型的电影中选择电影.我使用列表框来显示电影和流派的列表.当用户选择一种流派时,该流派的电影将显示在另一个列表框中.用户从该列表框中选择影片,然后将影片中的图片显示在图片框中,并将有关该影片的信息显示在文本框中.

现在,我要的是让用户单击按钮,一旦他们选择了电影,它就会显示一个带有按钮的消息框,询问他们是否确定要选择这部电影.如果用户单击是",则电影的图片和信息仍将像以前一样显示在屏幕上.如果用户单击否,则从屏幕上清除图片和信息,并且用户可以选择另一部电影.

我该怎么做?

I''m making a Windows form which allows people to select a film from different genres. I''ve used list boxes to display the list of films and genres. When a user selects a genre, the films from that genre are displayed in another list box. The user selects a film from that list box, then a picture from the film is displayed in a picture box and informtion for the film is displayed in a text box.

Now what I want is to have button which the user clicks, once they have selected the film, which displays a message box with buttons, that asks if they''re sure they want to choose this film. If the user clicks "Yes", the picture and info for the film are still displayed on screen as before. If user clicks no then the picture and info are cleared from the screen and the user can select another film.

How do I do this?

推荐答案

对于一个简单的消息框,请使用巧妙命名的
For a simple message box use the cleverly named MessageBox[^] class.

For a more complex dialog, create a new window and display it appropriately.


希望这会有所帮助
Hope this will help
if(MessageBox.Show("Your Message","Caption",MessageBoxButtons.YesNo)==DialogResult.Yes)
{
// write code here for yes
}
else
{
// here for no
}



--Pankaj



--Pankaj


这篇关于如何创建带有按钮的消息框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆