Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6098943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:12:58+00:00 2026-05-23T13:12:58+00:00

I want to use a custom icon in MessageBox.Show(Message, Title, MessageBoxButton.OK, MeesageBoxIcon.myIcon) Method. Any

  • 0

I want to use a custom icon in MessageBox.Show("Message", "Title", MessageBoxButton.OK, MeesageBoxIcon.myIcon) Method.

Any suggestion please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:12:59+00:00Added an answer on May 23, 2026 at 1:12 pm

    I wrote one a little while ago, it works exactly like the regular messagebox class.

    CustomMessageBox (Class): http://pastebin.com/m8evBmZi

    using System;
    using System.Drawing;
    using System.Windows.Forms;
    
    public static class CustomMessageBox
    {
        public static DialogResult Show(string Text, string Title, eDialogButtons Buttons, Image Image)
        {
            MessageForm message = new MessageForm();
            message.Text = Title;
    
            if (Image.Height < 0 || Image.Height > 64)
                throw new Exception("Invalid image height. Valid height ranges from 0 to 64.");
            else if (Image.Width < 0 || Image.Width > 64)
                throw new Exception("Invalid image width. Valid width ranges from 0 to 64.");
            else
            {
                message.picImage.Image = Image;
                message.lblText.Text = Text;
    
                switch (Buttons)
                {
                    case eDialogButtons.OK:
                        message.btnYes.Visible = false;
                        message.btnNo.Visible = false;
                        message.btnCancel.Visible = false;
                        message.btnOK.Location = message.btnCancel.Location;
                        break;
                    case eDialogButtons.OKCancel:
                        message.btnYes.Visible = false;
                        message.btnNo.Visible = false;
                        break;
                    case eDialogButtons.YesNo:
                        message.btnOK.Visible = false;
                        message.btnCancel.Visible = false;
                        message.btnYes.Location = message.btnOK.Location;
                        message.btnNo.Location = message.btnCancel.Location;
                        break;
                    case eDialogButtons.YesNoCancel:
                        message.btnOK.Visible = false;
                        break;
                }
    
                if (message.lblText.Height > 64)
                    message.Height = (message.lblText.Top + message.lblText.Height) + 78;
    
                return (message.ShowDialog());
            }
        }
    
        public enum eDialogButtons { OK, OKCancel, YesNo, YesNoCancel }
    }
    

    MessageForm (Form): http://pastebin.com/jawHZDzY

    using System;
    using System.Windows.Forms;
    
    internal partial class MessageForm : Form
    {
        internal MessageForm() => InitializeComponent();
    
        private void btnYes_Click(object sender, EventArgs e) =>
            DialogResult = DialogResult.Yes;
    
        private void btnNo_Click(object sender, EventArgs e) =>
            DialogResult = DialogResult.No;
    
        private void btnCancel_Click(object sender, EventArgs e) =>
            DialogResult = DialogResult.Cancel;
    
        private void btnOK_Click(object sender, EventArgs e) =>
            DialogResult = DialogResult.OK;
    }
    

    MessageForm (Designer Code): http://pastebin.com/CRXjeUFN

    partial class MessageForm
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;
    
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }
    
        #region Windows Form Designer generated code
    
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.picImage = new System.Windows.Forms.PictureBox();
            this.lblText = new System.Windows.Forms.Label();
            this.btnYes = new Dark.WinForms.Controls.dButton();
            this.btnNo = new Dark.WinForms.Controls.dButton();
            this.btnCancel = new Dark.WinForms.Controls.dButton();
            this.btnOK = new Dark.WinForms.Controls.dButton();
            ((System.ComponentModel.ISupportInitialize)(this.picImage)).BeginInit();
            this.SuspendLayout();
            //
            // picImage
            //
            this.picImage.ErrorImage = null;
            this.picImage.InitialImage = null;
            this.picImage.Location = new System.Drawing.Point(15, 15);
            this.picImage.Name = "picImage";
            this.picImage.Size = new System.Drawing.Size(64, 64);
            this.picImage.TabIndex = 0;
            this.picImage.TabStop = false;
            //
            // lblText
            //
            this.lblText.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                        | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.lblText.AutoSize = true;
            this.lblText.Location = new System.Drawing.Point(85, 15);
            this.lblText.MaximumSize = new System.Drawing.Size(294, 0);
            this.lblText.Name = "lblText";
            this.lblText.Size = new System.Drawing.Size(28, 13);
            this.lblText.TabIndex = 0;
            this.lblText.Text = "Text";
            //
            // btnYes
            //
            this.btnYes.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.btnYes.FocusDuesEnabled = false;
            this.btnYes.Location = new System.Drawing.Point(139, 88);
            this.btnYes.Name = "btnYes";
            this.btnYes.Size = new System.Drawing.Size(75, 23);
            this.btnYes.TabIndex = 2;
            this.btnYes.Text = "Yes";
            this.btnYes.Tooltip = "";
            this.btnYes.UseVisualStyleBackColor = true;
            this.btnYes.Click += new System.EventHandler(this.btnYes_Click);
            //
            // btnNo
            //
            this.btnNo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.btnNo.FocusDuesEnabled = false;
            this.btnNo.Location = new System.Drawing.Point(220, 88);
            this.btnNo.Name = "btnNo";
            this.btnNo.Size = new System.Drawing.Size(75, 23);
            this.btnNo.TabIndex = 3;
            this.btnNo.Text = "No";
            this.btnNo.Tooltip = "";
            this.btnNo.UseVisualStyleBackColor = true;
            this.btnNo.Click += new System.EventHandler(this.btnNo_Click);
            //
            // btnCancel
            //
            this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.btnCancel.FocusDuesEnabled = false;
            this.btnCancel.Location = new System.Drawing.Point(301, 88);
            this.btnCancel.Name = "btnCancel";
            this.btnCancel.Size = new System.Drawing.Size(75, 23);
            this.btnCancel.TabIndex = 1;
            this.btnCancel.Text = "Cancel";
            this.btnCancel.Tooltip = "";
            this.btnCancel.UseVisualStyleBackColor = true;
            this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
            //
            // btnOK
            //
            this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.btnOK.FocusDuesEnabled = false;
            this.btnOK.Location = new System.Drawing.Point(220, 88);
            this.btnOK.Name = "btnOK";
            this.btnOK.Size = new System.Drawing.Size(75, 23);
            this.btnOK.TabIndex = 4;
            this.btnOK.Text = "OK";
            this.btnOK.Tooltip = "";
            this.btnOK.UseVisualStyleBackColor = true;
            this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
            //
            // MessageForm
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(394, 129);
            this.Controls.Add(this.btnYes);
            this.Controls.Add(this.btnNo);
            this.Controls.Add(this.btnCancel);
            this.Controls.Add(this.picImage);
            this.Controls.Add(this.lblText);
            this.Controls.Add(this.btnOK);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "MessageForm";
            this.Padding = new System.Windows.Forms.Padding(15);
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "Title";
            ((System.ComponentModel.ISupportInitialize)(this.picImage)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();
    
        }
    
        #endregion
    
        internal Dark.WinForms.Controls.dButton btnCancel;
        internal Dark.WinForms.Controls.dButton btnNo;
        internal Dark.WinForms.Controls.dButton btnYes;
        internal Dark.WinForms.Controls.dButton btnOK;
        internal System.Windows.Forms.PictureBox picImage;
        internal System.Windows.Forms.Label lblText;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use an image or icon as a custom cursor in WPF
I have a listview extends Activity and use custom adapter because I want icon
I want to use custom exception handling, for example instead of using (Exception ex)
I want to use Custom URL Scheme to transfer data from application to other
For example I want to use custom logger: logger = require('basic-logger'), logger.setLevel('info') var customConfig
I want to use a custom template file which shoud use the base layout
I want to use a custom property to interact between controllers. Or do I
I want to use a custom class that could handle querying easily. Are there
I am having an issue in iphone when i want to use a custom
I want to use the Google Custom Search API (or custom search engine directly)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.