You need to create your own Window
, with a Label
and two Buttons
public partial class MeuMsgBox : Form
{
public MeuMsgBox()
{
InitializeComponent();
}
public DialogResult Resultado { get; private set; }
public static DialogResult Mostrar(string mensagem, string textoSim, string textoNao)
{
var msgBox = new MeuMsgBox();
msgBox.lblMensagem.Text = mensagem;
msgBox.btnSim.Text = textoSim;
msgBox.btnNao.Text = textoNao;
msgBox.ShowDialog();
return msgBox.Resultado;
}
private void btnSim_Click(object sender, EventArgs e)
{
Resultado = DialogResult.Yes;
Close();
}
private void btnNao_Click(object sender, EventArgs e)
{
Resultado = DialogResult.No;
Close();
}
}
Utilizing:
DialogResult resultado = MeuMsgBox.Mostrar("Minha pergunta?", "Clique em Sim", "Clique em não");
It’s up to you to work on the layout to look beautiful.
Did any of the answers solve your question? Do you think you can accept one of them? Check out the [tour] how to do this, if you haven’t already. You would help the community by identifying what was the best solution for you. You can accept only one of them. But you can vote on any question or answer you find useful on the entire site.
– Maniero