Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[VB.NET] Advanced MessageBox Control
#10
This is nice.
For the one's who want's this in C# this is it.
(i know is not much, but it will save you some time)


Code:
using System;
using System.Windows.Forms;

//    Author: Soul Collector
//    Comment: This example is coded for HF.NET & VBLeet.com
//    Date: 13/02/2010 - 20:02
//    MSN e-mail: soulcoll3ctor@live.com
//    Visit: Vbleet.com & Hackforums.net

namespace Advanced_MessageBox
{
    public partial class Form1
    {
        public Form1()
        {
            InitializeComponent();
            
            //Added to support default instance behavour in C#
            if (_defaultInstance == null)
                _defaultInstance = this;
        }
        
        #region Default Instance
        
        private static Form1 _defaultInstance;
        
        /// <summary>
        /// Added by the VB.Net to C# Converter to support default instance behavour in C#
        /// </summary>
        public static Form1 Default
        {
            get
            {
                if (_defaultInstance == null)
                {
                    _defaultInstance = new Form1();
                    _defaultInstance.FormClosed += DefaultInstanceFormClosed;
                }
                
                return _defaultInstance;
            }
        }
        
        static void DefaultInstanceFormClosed(object sender, FormClosedEventArgs e)
        {
            _defaultInstance = null;
        }
        
        #endregion
        public void Button1_Click(object sender, EventArgs e)
        {
            if (rbError.Checked && Ok.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (rbInformation.Checked && Ok.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (rbQuestion.Checked && Ok.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.OK, MessageBoxIcon.Question);
            }
            else if (rbWarning.Checked && Ok.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            
            if (rbError.Checked && OkCancel.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
            }
            else if (rbInformation.Checked && OkCancel.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
            }
            else if (rbQuestion.Checked && OkCancel.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
            }
            else if (rbWarning.Checked && OkCancel.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
            }
            
            if (rbError.Checked && YesNo.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Error);
            }
            else if (rbInformation.Checked && YesNo.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Information);
            }
            else if (rbQuestion.Checked && YesNo.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            }
            else if (rbWarning.Checked && YesNo.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
            }
            
            if (rbError.Checked && YesNoCancel.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Error);
            }
            else if (rbInformation.Checked && YesNoCancel.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);
            }
            else if (rbQuestion.Checked && YesNoCancel.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
            }
            else if (rbWarning.Checked && YesNoCancel.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
            }
            
            if (rbError.Checked && RetryCancel.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
            }
            else if (rbInformation.Checked && RetryCancel.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.RetryCancel, MessageBoxIcon.Information);
            }
            else if (rbQuestion.Checked && RetryCancel.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.RetryCancel, MessageBoxIcon.Question);
            }
            else if (rbWarning.Checked && RetryCancel.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
            }
            
            if (rbError.Checked && AbortRetryIgnore.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error);
            }
            else if (rbInformation.Checked && AbortRetryIgnore.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Information);
            }
            else if (rbQuestion.Checked && AbortRetryIgnore.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Question);
            }
            else if (rbWarning.Checked && AbortRetryIgnore.Checked)
            {
                MessageBox.Show(txtMsg.Text, txtTitle.Text, MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Warning);
            }
        }
    }
    
}

Download source in C#
Reply


Messages In This Thread
RE: [VB.NET] Advanced MessageBox Control - by nosferatus - 01-12-2011, 09:35 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [SOURCE] Advanced Webcam Viewer TalishHF 4 3,486 08-25-2014, 01:20 AM
Last Post: dark_move
  [TUT]Creating Advanced Web Browser with Awesome Theme Imaking31 0 1,320 05-25-2013, 03:12 AM
Last Post: Imaking31
  Free Advanced Port Scanner SOURCE [ VB.NET ] Filefinder 6 5,354 01-22-2013, 04:27 AM
Last Post: TalishHF
  How To make an advanced Operating System in Visual Basic 2010 ? Mohamed Samir 9 11,527 01-15-2013, 09:30 PM
Last Post: Resistance
  vb6.0 SSTab control disappeared DanB 0 1,198 12-29-2012, 10:24 AM
Last Post: DanB

Forum Jump:


Users browsing this thread: 1 Guest(s)