CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 1999
    Posts
    134

    How do I add an option button to a form at runtime? plz help

    help!


  2. #2
    Guest

    Re: How do I add an option button to a form at runtime? plz help

    in VB6 only:

    private withevents btnObj as OptionButton

    private Sub Form_Load()
    set btnObj = Controls.Add("VB.OptionButton", "btnObj")
    With btnObj
    .Visible = true
    .Width = 2000
    .Caption = "Dynamic Button"
    .Top = 1000
    .Left = 1000
    End With
    End Sub
    'for more sample see MSDN Dynamic Control Addition



    In VB5 you have to have at least 1 option button with Index = 0 (Array), and using Load statement you can add new elements to that array:

    Load Option1(1)
    Option1(1).Top=2000
    ........



    You can do it ofcourse in VB6 too.
    Vlad



  3. #3
    Join Date
    Nov 1999
    Posts
    134

    Re: How do I add an option button to a form at runtime? plz help

    thanks so much Vlad! <bow>


  4. #4
    Guest

    Re: How do I add an option button to a form at runtime? plz help

    Why not just add the option control to your form, set it's visible property to false at design time and toggle this property as needed at run-time in the corresponding events.


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

Featured