[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

Ruby on Rails Engine - How To Keep Your Engine Migrations Abstracted From Your Host Rails App

by Jey Geethan | January 16, 2019
Ruby on Rails Engine - How To Keep Your Engine Migrations Abstracted From Your Host Rails App
Have you ever worked on building a Rails Engine and wanted to keep the models, the migrations and everything inside the engine rather than using a generator to copy paste them into your host Rails App?
Software Development

How to get informative, color prompts on Mac Terminal or iTerm2

by Jey Geethan | August 14, 2019
How to get informative, color prompts on Mac Terminal or iTerm2
This article talks about how to get color prompts on your terminal and add some informative things like current git branch and distinctive colors for current path, username etc.