If you use the following code snippet, once you click one of the buttons, immediately pressing the Spacebar will close the message as if the button was clicked:
private void radButton1_Click(object sender, EventArgs e)
{
RadMessageBox.Show("Test", "Caption", MessageBoxButtons.OK);
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("Test", "Caption", MessageBoxButtons.OK);
}
However, if you switch to the following approach, once you click one of the buttons, immediately pressing the Spacebar will close the standard MS MessageBox as if the button was clicked, but the RadMessageBox wouldn't be closed because the message doesn't have focus.
private void radButton1_Click(object sender, EventArgs e)
{
RadMessageBox.Show(this, "Test", "Deployment Result", MessageBoxButtons.OK, RadMessageIcon.Info);
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(this, "Test", "Deployment Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
No matter how the RadMessageBox is shown, it is expected to have focus to the message button by default.
Workaround:
this.TopMost = true;
RadMessageBox.Show(this, "Test", "Deployment Result", MessageBoxButtons.OK, RadMessageIcon.Info);
Follow the code:
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
RadControl.EnableRadAutoScale = true;
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
string text = "Are you sure you want to exit?";
string caption = "Application";
RadMessageIcon icon = RadMessageIcon.Question;
RadMessageBox.Show(text, caption, MessageBoxButtons.YesNo, icon);
RadMessageBox.Show(text, caption, MessageBoxButtons.YesNoCancel, icon);
When the application is run on a main monitor with 125% DPI scaling, the following result is observed:
Workaround:
RadControl.EnableRadAutoScale = false;
when set RadMessageBox.UseCompatibleTextRendering = false;
at runtime is generated System.StackOverflowException.
To workaround:
private void RadForm1_Load(object sender, EventArgs e)
{
foreach (Control control in RadMessageBox.Instance.Controls)
{
RadControl radControl = control as RadControl;
if (radControl != null)
{
radControl.UseCompatibleTextRendering = false;
}
}
}