Results 1 to 4 of 4

Thread: How can I add a UserControl Dynamically [resolved]

  1. #1

    Thread Starter
    Fanatic Member ahara's Avatar
    Join Date
    Nov 2003
    Location
    Toronto
    Posts
    531

    How can I add a UserControl Dynamically [resolved]

    Hello;

    I am trying to add a simple user control to the controls collection at runtime. Is this possible to do? I keep getting the error: invalid progID...I am not sure if I just don't know the right syntax, or maybe this is not possible.

    As a side note, this control is embedded into the project and I do not want to compile it as a separate .ocx (not worth the additional deployment burdens)...does it still not generate a progID at runtime that I can reference? I have tried:

    VB.UserControl.MultiLineText (control name is MultiLineText)
    UserControl.MultiLineText

    The root cause of all this mess is wanting to generate the whole form at runtime, but for multiline textboxes, the properties MultiLine and ScrollBars are not available at runtime, so any other ideas for how I can get around this are more than welcome. Thanks.
    Last edited by ahara; May 29th, 2004 at 07:47 AM.
    "Knowledge is gained when different people look at the same information in different ways"

    - Louis Pasteur

  2. #2
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246
    You can use a Control Array.

    Firstly, in design mode, copy the usercontrol and paste it again. Visual Basic will ask if you want to create a Control array; click yes. Now, delete the newly made usercontrol. In code, try this now..
    VB Code:
    1. Load UserControl11(1)
    2. UserControl11(1).Visible = True
    3. UserControl11(1).Top = UserControl11(0).Top + UserControl11(0).Height

    Phreak

    Visual Studio 6, Visual Studio.NET 2005, MASM

  3. #3

    Thread Starter
    Fanatic Member ahara's Avatar
    Join Date
    Nov 2003
    Location
    Toronto
    Posts
    531
    oh man I can't believe I didn't think of that...thanks a bunch!
    "Knowledge is gained when different people look at the same information in different ways"

    - Louis Pasteur

  4. #4
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246
    Heres an example of it in action:

    Phreak
    Attached Files Attached Files

    Visual Studio 6, Visual Studio.NET 2005, MASM

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