Software Development

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

by Jey Geethan

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.



Related Articles

Show full file path in the title bar of Sublime and VS Code

Software Development

If you feel that you want to show the full file paths in your favorite editors - Sublime Text and Visual Studio Code, follow the simple steps

by Jey Geethan

What's next after Chatbots?

Software Development

Chatbots are programmatically defined workflows that can help any customer to navigate some scenarios. But will chatbots stay there?

by Jey Geethan


Subscribe to my weekly newsletter
Subscribe to my weekly newsletter to receive emails on business, love, my books, poems and my other writings