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

    Creating a Button at Runtime

    How I can create a CommandButton at runtime???

    Thanks
    Arnaldo


  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Creating a Button at Runtime

    There are many examples here in CodeGuru. Use the search option (on top left of page). Or have a look at this:
    http://codeguru.com/cgi-bin/bbs/wt/s...age=0&Limit=25


    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  3. #3
    Join Date
    Oct 2000
    Location
    Upstate NY
    Posts
    249

    Re: Creating a Button at Runtime

    Have the button on your form but make it invisible
    When you want it to appear
    Command1.Visible = true
    73 RSH


  4. #4
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Creating a Button at Runtime

    You may also have a button invisible with index = 0 and when you need one more, you can use the load statement incrementing index
    ie:

    load command1(ubound(command1+1))
    with command1(ubound(command1))
    left=command1(ubound(command1)-1).left +command1(ubound(command1)-1).width
    top=command1(ubound(command1)-1).top
    caption="AAA"
    visible = true
    end with




    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  5. #5
    Join Date
    Jul 2001
    Location
    maharashtra,india
    Posts
    181

    Re: Creating a Button at Runtime

    private withevents cmd as commandbuttons
    'on any events
    set cmd = controls.add("vb.commandbutton","name")
    cmd.visible=true


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