Reputation: 8350
I want to show messagebox to the user, such that the user cannot refuse to confirm the message box. User should not be allowed to do anything else in the screen until he confirms the messagebox. This is a windows based c# application. The main thing is, even if i use windows message box. Some times it is hiding behind some screen. But for my case, i want message box to be on top most whenever it appears. I am using some other third party applications, which over rides my message box. I want to overcome this. How to do this...
Upvotes: 0
Views: 2169
Reputation: 23103
Always specify a owner when displaying a message box.
Upvotes: 0
Reputation: 13384
You might have to define a custom message box (a Form
) and set its TopMost
property to true
.This will make it on top of ever other window, except other TopMost
windows.
That's assuming you want it on top of other applications too, which I'm not sure it's what you're looking for...
Upvotes: 1
Reputation: 94653
Invoke messagebox inside the constructor of your form.
public Form1()
{
if (MessageBox.Show(this, "Confirm?", "Attention", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
{
}
else
{
}
InitializeComponent();
}
OR
Invoke another form instance using ShowDialog() method,
public Form1()
{
Form2 frm=new Form2();
frm.ShowDialog(this);
}
Upvotes: 1
Reputation: 34375
The normal windows MessageBox() function should do exactly this unless I'm missing something in your question.
Upvotes: 0