Results 1 to 5 of 5

Thread: User Control Question

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 1999
    Location
    Australia
    Posts
    115
    I'm trying to create user control based on the combo box control, because I'd like to include some properties that I can use throughout the application.

    I have problem inheriting the Style property, as this property can only be set at design time. Any suggestions on how I can solve this problem?

    Thanks.


  2. #2
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    You can put a validation routine in your property let to stop the user setting this propery at run time, something like
    Code:
    if not usercontrol.ambient.usermode then
    
        cboChild.Style=NewStyle
    
    End IF
    usercontrol.ambient.usermode returns true at runtime and false at design time so the user will not be able to set the style at runtime.

    If that's not good enough your going to have to create 3 combo boxes in your control and flip between them, or start from scratch.

    Hope this helps


  3. #3
    Fanatic Member Bonker Gudd's Avatar
    Join Date
    Mar 2000
    Location
    Saturn
    Posts
    748
    You cannot change design only properties in a User Control.
    You will have to include a new Combo Box in your Control for each style you want to use. In the code, make the appropriate Combo visible depending upon which Style you want.

  4. #4
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    Rotterdam, Netherlands
    Posts
    386
    Indeed, never forget that any control that you place on a usercontrol, is run-time for that control. So it is always impossible to set that kind of properties (at least not with plain VB code). Another example is the multiline property of a textbox that you use on a usercontrol; you can't set that 'cause it's runtime for the textbox, although for your control it's designtime.

  5. #5
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    Yeah, I should have noticed that last one, If you're any good with the API it's probably worth starting from scratch, if you have 3 comboboxes then that will take up 4 times the memory of a single combo box, (once for each combo and once for the usreconrol itself.) Plus if you start from scratch you can make the combo box lok exagtly how you want it to. If that seems too much like hard work then dont bother.

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