目的:当点击保存按钮时,希望提示“保存成功”,但是又不想用户去点确定按钮,并且这个提示框不会对主线程产生影响。
[DllImport("user32.dll")]//1.这是必须的
public static extern int MessageBoxTimeoutA(IntPtr hWnd, string msg, string Caps, int type, int Id, int time); //2.这是必须的,1-2必须写到方法前
private void button35_MouseUp(object sender, MouseEventArgs e)
{
MessageBoxTimeoutA((IntPtr)0, "数据保存成功", "消息框", 0, 0, 500); // 直接调用 500毫秒后自动关闭
button_NumberSave.Text = "保存数据";
button_NumberSave.BackColor = Color.LightSeaGreen;
button_NumberSave.Enabled = true;
}