日期:2014-05-18  浏览次数:20438 次

MsgBox為什么要点击两次确认?
VB.NET code


 MsgBox("確認刪除這條數據嗎", MsgBoxStyle.YesNo)//要点击两次确认
  Dim resultCode As Integer = 0


        resultCode = MsgBox("asd", MsgBoxStyle.YesNo).GetHashCode

        If resultCode = MsgBoxResult.Yes Then
end 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#代码