65.9K
CodeProject is changing. Read more.
Home

Custom MessageBox with checkbox

starIconstarIconstarIconstarIconstarIcon

5.00/5 (4 votes)

Sep 11, 2016

CPOL
viewsIcon

17621

downloadIcon

998

This is a simple class that allows you to have message box with checkbox and other small features.

Introduction

I found myself in need of a classical messagebox with checkbox but all the classes I've tried writing in the register Windows preference, however I needed to write the result in the personal .ini setting of the program and so I decided to develop a class of my own that returned the value of the DialogResult and checkbox.

Using the Code

Using the class is very simple. Add the class and resource file to your project and you can use one of the examples attached to the project.

Dim check As Boolean = False
Dim reslt As DialogResult = myMsgBox.Show("writing test 1",
                            "Test", myMsgBox.Buttons.OK, myMsgBox.Icon.Information, 
                            "do not ask me again", check)

There are 32 different combinations of messagebox (with or without checkboxes, custom fonts, buttons with custom text and more).

Constants are present at the start of the sheet to vary text and size of the messagebox.

  Const frmminWidth As Integer = 345
  Const frmminHeight As Integer = 160
 
  Const frmmaxWidth As Integer = 800
  Const frmmaxHeight As Integer = 600
 
  Const txtminWidth As Integer = 250
  Const txtminHeight As Integer = 60
 
  Const txtmaxWidth As Integer = 700
  Const txtmaxHeight As Integer = 500
 
  'changes the text of the tests according to your language and preference
  Const txt_OK As String = "Ok"
  Const txt_Cancel As String = "Cancel"
  Const txt_Abort As String = "Abort"
  Const txt_Retry As String = "Riprova"
  Const txt_Ignore As String = "Ignora"
  Const txt_Yes As String = "Si"
  Const txt_No As String = "No"

The icons in the resource files have been downloaded from here.

History

  • September 11, 2016 - First posting