RSS Feed for This PostCurrent Article

C# UserControl: Detect Design Mode

When developing a user control in .NET, if certain codes are not meant to be run in design mode, then you should check for it and avoid executing those code

   1: /// <summary>

   2: /// Handles the Load event of the MenuPanel control.

   3: /// </summary>

   4: /// <param name="sender">The source of the event.</param>

   5: /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>

   6: private void MenuPanel_Load(object sender, EventArgs e)

   7: {

   8:    if (this.DesignMode) return;

   9:  

  10:    // Load the menu

  11:    LoadMenu();

  12: }


Trackback URL


RSS Feed for This PostPost a Comment

CAPTCHA Image
Refresh Image
*