Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Custom MessageBox with checkbox

0.00/5 (No votes)
11 Sep 2016 1  
This is a simple class that allows you to have message box with checkbox and other small features.

<img alt="" src="http://www.codeproject.com/KB/Articles/1127411/Img_3.jpg" style="width: 640px; height: 246px;" />

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).

<img src="http://www.codeproject.com/KB/Articles/1127411/Img_1.jpg" style="height: 85px; width: 640px;" />

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

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here