This is a migrated thread and some comments may be shown as answers.

RadMessageBoxForm.MessageIcon

6 Answers 289 Views
MessageBox
This is a migrated thread and some comments may be shown as answers.
PBrilliant
Top achievements
Rank 1
PBrilliant asked on 15 Feb 2013, 04:15 AM
Why MessageIcon doesn't accept RadMessageIcon.Error as it's value and reports : "Cannot implicitly convert type 'Telerik.WinControls.RadMessageIcon' to 'System.Drawing.Bitmap'" ?

6 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 19 Feb 2013, 07:58 AM
Hi,

Thank you for writing.

Could you please provide me with the code producing this error, since on my end, I am able to use RadMessageIcon.Error without any issues - see attached video. The video opens in browser and requires Shockwave flash player to play.

I am looking forward to your reply.
 
Regards,
Stefan
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
0
PBrilliant
Top achievements
Rank 1
answered on 19 Feb 2013, 12:15 PM
Hi , thanks for your reply.
Your video examples RadMessageBox instead of RadMessageBoxForm.
Here's my code :
RadMessageBoxForm RM = new RadMessageBoxForm();
RM.Text = "...";
RM.MessageIcon = RadMessageIcon.Error;
0
Accepted
Stefan
Telerik team
answered on 22 Feb 2013, 08:30 AM
Hi,

RadMessageBoxForm is not indented for usage outside the context of RadMessageBox, so I would suggest using RadMessageBox, not RadMessageBoxForm.

However, for your convenience, the MessageIcon property accepts object of type Bitmap. Here is a helper method you could use to do that:
void radButton1_Click(object sender, EventArgs e)
{
    RadMessageBoxForm RM = new RadMessageBoxForm();
    RM.Text = "...";
    RM.MessageIcon = GetRadMessageIcon(RadMessageIcon.Error);
    RM.Show();
}
 
private static Bitmap GetRadMessageIcon(RadMessageIcon icon)
{
    Stream stream;
    Bitmap image;
 
    switch (icon)
    {
 
        case RadMessageIcon.Info:
            stream = (System.Reflection.Assembly.GetAssembly(typeof(RadMessageBox)).
                GetManifestResourceStream("Telerik.WinControls.UI.Resources.RadMessageBox.MessageInfo.png"));
            image = Bitmap.FromStream(stream) as Bitmap;
            stream.Close();
            return image;
        case RadMessageIcon.Question:
            stream = (System.Reflection.Assembly.GetAssembly(typeof(RadMessageBox)).
                GetManifestResourceStream("Telerik.WinControls.UI.Resources.RadMessageBox.MessageQuestion.png"));
            image = Bitmap.FromStream(stream) as Bitmap;
            stream.Close();
            return image;
        case RadMessageIcon.Exclamation:
            stream = (System.Reflection.Assembly.GetAssembly(typeof(RadMessageBox)).
                GetManifestResourceStream("Telerik.WinControls.UI.Resources.RadMessageBox.MessageExclamation.png"));
            image = Bitmap.FromStream(stream) as Bitmap;
            stream.Close();
            return image;
        case RadMessageIcon.Error:
            stream = (System.Reflection.Assembly.GetAssembly(typeof(RadMessageBox)).
                GetManifestResourceStream("Telerik.WinControls.UI.Resources.RadMessageBox.MessageError.png"));
            image = Bitmap.FromStream(stream) as Bitmap;
            stream.Close();
            return image;
    }
 
    return null;
}

I hope this helps.

Kind regards,
Stefan
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
0
Brendan
Top achievements
Rank 1
answered on 18 Mar 2015, 10:10 PM
Hi Stefan, I am using code similar to yours to display a Message box during load which includes a splash screen.  This way I can force it to be topmost, unlike the RadMessageBox.

Question, can a theme be set for the RadMessageBoxForm?  I tried .ThemeName and it didn't work.
0
Brendan
Top achievements
Rank 1
answered on 19 Mar 2015, 12:43 AM
Forget my earlier message, I figured it out.  I had to create an instance of the theme in code.

Thanks
0
Dimitar
Telerik team
answered on 23 Mar 2015, 11:18 AM
Hello Brendan,

Thank you for writing. 

You are correct, you should have a theme instance created before you can use the theme. In addition, I want to mention that we have an article that describes how you can create a splash form: Add SplashScreen to your application.

I hope this will be useful. 

Regards,
Dimitar
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
MessageBox
Asked by
PBrilliant
Top achievements
Rank 1
Answers by
Stefan
Telerik team
PBrilliant
Top achievements
Rank 1
Brendan
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or