Prevent the designer from trying to run specific code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Falkeli
    New Member
    • Feb 2012
    • 19

    #1

    Prevent the designer from trying to run specific code

    I'm writing a WinForms program, in which I have some user controls. Some of these user controls need to do things before being displayed, which cause the designer not to be able to use these controls. I've tried moving the relevant code from the constructor to the Load event, but it's still crashing the designer. Where should I put this code?
  • PsychoCoder
    Recognized Expert Contributor
    • Jul 2010
    • 465

    #2
    Depends on what the code it and what you're trying to accomplish. Show us the code that's causing the problems, and what kind of user control is it?

    Comment

    • Falkeli
      New Member
      • Feb 2012
      • 19

      #3
      One of these is a "Category dropdown". It's a ComboBox populated by a list of categories fetched from the disk. In design mode, this file can't be accessed, so an exception is thrown. I currently have this wrapped in a try/catch block with an empty catch, but this means that should there be any exception while running the code in runtime, I'll get an ignored exception which could end up complicating other things.

      Comment

      Working...