Results 1 to 5 of 5

Thread: [resolved] Dynamic controls...

  1. #1

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091

    [resolved] Dynamic controls...

    In VB6, you can add a control to a form by its name, ie
    VB Code:
    1. Controls.Add("VB.Label","SomeLabel")

    Does such a beast exist in .NET? In other words, I don't necessarily want to have to declare something as a Textbox in order to add it to the form. I would like to declare a Control, and be able to choose what the type of control it will be at run time.

    Last edited by crptcblade; May 29th, 2003 at 09:16 PM.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  2. #2
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Re: Dynamic controls...

    Originally posted by crptcblade
    In VB6, you can add a control to a form by its name, ie
    VB Code:
    1. Controls.Add("VB.Label","SomeLabel")

    Does such a beast exist in .NET? In other words, I don't necessarily want to have to declare something as a Textbox in order to add it to the form. I would like to declare a Control, and be able to choose what the type of control it will be at run time.

    hmm I dont quite understand what you want to do. couldn't you just do something like this?

    VB Code:
    1. dim ctrl as control
    2.  
    3. if true = true then
    4.     ctrl = new textbox()
    5. else
    6.     ctrl = new label
    7. end if
    8.  
    9. me.controls.add ctrl
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  3. #3

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Not really, I don't think.

    Written in VB6 already, I have a main container app (MDI), and it dynamically loads child forms and loads snap-in usercontrols by their ProgID (example - "SomeLib.SomeUsercontrol") onto the child form.

    Can you think of a way to translate that into .NET?

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  4. #4

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Know what? Never mind...I just realized I could probably just change the usercontrol to a form, and load it into the MDI container as the entire form. Stupid VB6 has corrupted my thinking.

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  5. #5
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by crptcblade

    Can you think of a way to translate that into .NET?

    get webster's new vb6 to vb.net pocker translator
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

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