1
メッセージボックスDialogResult、と私はここに私のコードのほとんどで、ショー()メソッドをオーバーライド:カスタムボタンのイベントここでカスタム私はまた、カスタムボタンとカスタムC#のメッセージボックスを持つ
public partial class CustomMessageBox : Form
{
public CustomMessageBox()
{
InitializeComponent();
}
#region Variables
public static CustomMessageBox MsgBox;
public static DialogResult result;
public enum CustomMessageBoxButtons { Ok, OkCancel }
public enum CustomMessageBoxTxtBoxState { VisibleChar, PasswordChar, VisibleCharReadOnly }
#endregion
public static DialogResult Show(string text, string title, CustomMessageBoxButtons buttons)
{
MsgBox = new CustomMessageBox();
MsgBox.txtbox_content.Text = text;
MsgBox.lbl_Title.Text = title;
result = DialogResult.No;
if (buttons == CustomMessageBoxButtons.Ok)
{
MsgBox.btn_ok.Location = new Point(86, 70);
MsgBox.btn_cancel.Visible = false;
}
MsgBox.ShowDialog();
return result;
}
private void btn_ok_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.OK;
}
private void btn_cancel_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
}
private void btn_close_Click(object sender, EventArgs e)
{
this.Close();
}
私は私のメッセージを呼び出すと
問題はここ
private void flatButton1_Click(object sender, EventArgs e)
{
if (CustomMessageBox.Show("Title", "TITLEEE", CustomMessageBox.CustomMessageBoxButtons.OkCancel) ==**CustomMessageBox.MsgBox.result.Yes**)
{
CustomMessageBox.Show("Aceptaste", "AGREED", CustomMessageBox.CustomMessageBoxButtons.Ok);
}
else
{
CustomMessageBox.Show("Rechazaste", "dENIED", CustomMessageBox.CustomMessageBoxButtons.Ok);
}
}
#endregion
ですそれは
代わりにName型でのWinFormsインスタンスリファレンス、QualifyItでアクセスすることができませんか?私を投げボックスを言っ
CustomMessageBox.MsgBox.result.Yes
上のエラーは私は何ができる
を使用してみてくださいMy MessageBoxではないので、 'DialogResult.Yes'で行われた式はMyMessageBoxでは機能しません。 – Hydralisk
' Show'メソッドの戻り値の型は 'DialogResult'です。したがって、 'Show'メソッドによって返される戻り値は、' DialogResult' enumメンバーとしか比較できません。 –