logo  VB.Net - Examples of User Controls
This Chapter
User Controls
Date Picker
Roll a Dice
Integer Picker
Integer Up/Down
Chapters
Home Page
Colours, RGB
Computer Specifications
Dates&Times
Disk Drives
Files
Folders
GPS and OS Ref
VB.Net Forms
Image Files
If & Select
List/Array
Mathematics
NuGet
Sound
String Functions
Sun and Moon
User Controls
Validation
DigitalDan Sites
My Other Sites
Contact Site

Note
Some pages
may contain
inaccuracies
Hits=4
User Controls
This section of the website concentrates on User-Controls. It provides basic instructions and code for adding new controls to a VB.Net project. There are instructuctions at the end of this page to overcome a specific compiler error which may occur when using certain versions of VB.Net
How To Add This Sites User Controls to Your Project
These instructions are based on a VB.Net 2026 version. There may be slight differences when using other VB.Net versions.

 
Compilation Problem - The Public Property... lines
Information is normally passed between programs and user controls using a special type of "parameter" known as a property. Older versions of VB.Net defined a property using similar code to this

Public Property MyProperty As Integer
 Get
  Return _MyProperty1
 End Get
 Set(value As Integer)
  _MyProperty1 = value
 End Set
End Property
  
Some versions of VB.Net will not accept this code and you could encounter errors pointing to the line

Public Property MyProperty As Integer
  
If you experience this problem, try adding the compiler instruction

<DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)>
  
Insert the line immediately before the Public Property ... line and ensure the line starts with < and ends with >
(Avoid placing any comments, blank lines or other code between <Designer.... and Public Property)

<DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)>
Public Property MyProperty As Integer
 Get
  Return _MyProperty1
 End Get
 Set(value As Integer)
  _MyProperty1 = value
 End Set
End Property
  
It is possible that an older version of VB.Net could complain about the <Designer... instruction - if this happens, try commenting out the <Designer... line

' <DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)>
Public Property MyProperty As Integer
 Get
  Return _MyProperty1
 End Get
 Set(value As Integer)
  _MyProperty1 = value
 End Set
End Property
  
The line
Imports System.ComponentModel
is required by the
<DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)>
line. If your version of VB.Net does not require
<DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)>
you may also have to comment out the
Imports System.ComponentModel
 

DigitalDan.co.uk