如何更改为“是”和“否”的MessageBox.Show对话框按钮,按钮上的文字? [英] How to change the button text for 'Yes' and 'No' buttons in the MessageBox.Show dialog?
本文介绍了如何更改为“是”和“否”的MessageBox.Show对话框按钮,按钮上的文字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要改变的消息框控制按钮是
到继续
和否
到关闭
。怎么样
我改变按钮的文字?
下面是我的code:
的DialogResult dlgResult = MessageBox.Show(模式已经成功登录,Logtool,MessageBoxButtons.YesNo,MessageBoxIcon.Information);
解决方案
只需添加一个新的形式,并添加按钮和标签。给要显示的值和按钮等在其构造的文本,从任何地方调用它,你在项目中想要的。
在项目 - >添加组件 - > Windows窗体,并选择一种形式
添加一些标签和按钮。
在初始化构造函数中的值,并从任何地方调用它。
公共Form1类:System.Windows.Forms.Form中
{
公共Form1中()
{
} 公共Form1中(字符串消息,串buttonText1,串buttonText2)
{
lblMessage.Text =消息;
button1.Text = buttonText1;
button2.Text = buttonText2;
}
}//为了调用write code为Button1和按钮2的单击事件
//从当前项目任何地方。//调用Form1的FRM =新Form1的(信息显示,buttontext1,buttontext2);
frm.ShowDialog();
I need to change the message box control buttons Yes
to Continue
and No
to Close
. How
do I change the button text?
Here is my code:
DialogResult dlgResult = MessageBox.Show("Patterns have been logged successfully", "Logtool", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
解决方案
Just add a new form and add buttons and a label. Give the value to be shown and the text of the button, etc. in its constructor, and call it from anywhere you want in the project.
In project -> Add Component -> Windows Form and select a form
Add some label and buttons.
Initialize the value in constructor and call it from anywhere.
public class form1:System.Windows.Forms.Form
{
public form1()
{
}
public form1(string message,string buttonText1,string buttonText2)
{
lblMessage.Text = message;
button1.Text = buttonText1;
button2.Text = buttonText2;
}
}
// Write code for button1 and button2 's click event in order to call
// from any where in your current project.
// Calling
Form1 frm = new Form1("message to show", "buttontext1", "buttontext2");
frm.ShowDialog();
这篇关于如何更改为“是”和“否”的MessageBox.Show对话框按钮,按钮上的文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文