[VB.NET] Finding whether its Design Mode or Runtime Mode for Forms

[VB.NET] Finding whether its Design Mode or Runtime Mode for Forms

Sometimes, while creating controls, either by Inherited Controls or UserControls, we will be required to skip a piece of code depending upon the design time or runtime mode.
Software Development
by Jey Geethan | November 06, 2008

Sometimes, while creating controls, either by Inherited Controls or UserControls, we will be required to skip a piece of code depending upon the design time or runtime mode. This can be done easily by the following code inside a control.


If Me.Site IsNot Nothing AndAlso Me.Site.DesignMode = True Then
    'Designtime code here
Else
    'Runtime code here
End If


Using this code in a control, we can find the mode and avoid certain errors when in Design Mode. This is mostly used in overridden event methods in Inherited Controls.


Jey Geethan

Jey Geethan is a poet, author and an entrepreneur.


Related Articles

Software Development

Do you want to use your macbook as a lap-heater?

by Jey Geethan | August 28, 2019
Do you want to use your macbook as a lap-heater?
How many times have you felt the coldness of a meeting room and wish you had brought a heater into the room. Now you can convert your macbook into a heater
Software Development

Solving - xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

by Jey Geethan | March 16, 2018
Solving - xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
If you recently updated to macOS High Sierra and tried to run git commands you would face this error