Results 1 to 1 of 1

Thread: Dynamic controls in user controls

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2002
    Posts
    235

    Dynamic controls in user controls

    Here’s the short version: Is it “Acceptable Design Practice” to put code other than propBag.ReadProperties calls into UserControl_ReadProperties?

    Now the long version:

    I have made a user control (we'll call it MainControl here) that can contain any number of controls (named subControl and a user control itself), as indicated by a property (numOfSubControl).

    When I put MainControl in a form, and change numOfSubControl at design time, the proper number of subControls are drawn in the designer window. Likewise, changing the number of subControls at runtime redraw the control correctly.

    However, when I change numOfSubControl in design time and then run the program, it does not show the proper number of subControls. So it seems that I have the code correct for changing the property, but I don’t have the code that reads numOfSubControl’s value and draws the correct number of subControls accordingly when the program first launches.

    From what I can tell, the problem with my code right now is that Initialize is called before ReadProperties. So as I was writing this, I realized that I could move my code that’s currently in Initialize into ReadProperties. Is that the best way to solve this problem, or is that klunky?

    I’ve attached the code in case anyone finds it easier to understand the problem that way.

    Thanks,
    Carole
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width