当前位置: 代码迷 >> ASP.NET >> MsgBox為什么要端击两次确认
  详细解决方案

MsgBox為什么要端击两次确认

热度:7979   发布时间:2013-02-25 00:00:00.0
MsgBox為什么要点击两次确认?
VB.NET code
 MsgBox("確認刪除這條數據嗎", MsgBoxStyle.YesNo)//要点击两次确认  Dim resultCode As Integer = 0        resultCode = MsgBox("asd", MsgBoxStyle.YesNo).GetHashCode        If resultCode = MsgBoxResult.Yes Thenend if


------解决方案--------------------------------------------------------
If MsgBox("asd", MsgBoxStyle.YesNo).GetHashCode == DialogResult.Yes Then
试试,我不是很懂vb,你查一下msdn,只用一行代码或者用DialogResult枚举,就会只点一次。原理大概是因为MsgBoxResult.Yes 又实例化了一次,好像,记不得了

------解决方案--------------------------------------------------------
C# code
private void button1_Click(object sender, EventArgs e)        {            if (MessageBox.Show("hegheheh","warning",MessageBoxButtons.YesNo)== DialogResult.Yes)             {                this.label1.Text = "sucess";            }        }
------解决方案--------------------------------------------------------
探讨
C# code
private void button1_Click(object sender, EventArgs e)
{
if (MessageBox.Show("hegheheh","warning",MessageBoxButtons.YesNo)== DialogResult.Yes)
{
this.label1.Text = "sucess";
}
}



C#代码