RadMessageBoxForm.MessageIcon

7 posts, 1 answers
  1. PBrilliant
    PBrilliant avatar
    3 posts
    Member since:
    Feb 2013

    Posted 14 Feb 2013 Link to this post

    Why MessageIcon doesn't accept RadMessageIcon.Error as it's value and reports : "Cannot implicitly convert type 'Telerik.WinControls.RadMessageIcon' to 'System.Drawing.Bitmap'" ?

  2. Stefan
    Admin
    Stefan avatar
    2890 posts

    Posted 19 Feb 2013 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. PBrilliant
    PBrilliant avatar
    3 posts
    Member since:
    Feb 2013

    Posted 19 Feb 2013 Link to this post

    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;
  5. Answer
    Stefan
    Admin
    Stefan avatar
    2890 posts

    Posted 22 Feb 2013 Link to this post

    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.
  6. Brendan
    Brendan avatar
    52 posts
    Member since:
    Dec 2011

    Posted 18 Mar 2015 in reply to Stefan Link to this post

    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.
  7. Brendan
    Brendan avatar
    52 posts
    Member since:
    Dec 2011

    Posted 18 Mar 2015 Link to this post

    Forget my earlier message, I figured it out.  I had to create an instance of the theme in code.

    Thanks
  8. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 23 Mar 2015 Link to this post

    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.

     
Back to Top
UI for WinForms is Visual Studio 2017 Ready