ButtonArray

I see that VB 2005 has a ButtonArray component in the Toolbox. Unfortunately, I've not been able to figure out how to use this component. I drag it out of the Toolbox, on to my form and it just sits there below the form. I'd appreciate some assistance on how to use this component to create an array of buttons. Thanks.


Answer this question

ButtonArray

  • Bose39814

    You can use the Controls collection for your form to iterate through the Buttons and set properties; you can also use shared event handlers to emulate the way Control Arrays were handled in VB 6.

    The topic "Control Arrays for Visual Basic 6.0 Users" contains examples of both. I can't seem to get to MSDN to provide a link at the moment, but if you look in the Index for your local Help you will find it under "control arrays".

    Hope this helps,

    Steve



  • Jose Miguel Torres

    Hi GrandpaB,

    The ButtonArray is a part of the Microsoft.VisualBasic.Compatibility namespace; it's primarily there for use by the upgrade tool when upgrading VB 6 apps.

    There is no reason that you can't use the controls and functions in this namespace, but they aren't documented so you are on your own. In general though, you are better off learning the ".Net" way of programming rather than using these upgrade functions.

    Hope this helps,

    Steve Hoag

    Visual Basic Express



  • Hilary Cotter

    hi,

    is that VB 2005 express edition where is that control i never see it b4

    best regards



  • Alexb1115

    Steve,

    I could use some assistance with the ".Net" way. I have 27 buttons, named btnAll, btnA, btnB, ..., BtnZ. I would like to programmtically go through each button and set various properties. The buttons are not contained in a GroupBox. Have you a suggestion Thanks.



  • aajrb

    shoagMSFT,

    Thanks, I have never iterated through a a collection of controls. The routine in the reference that you quoted (http://msdn2.microsoft.com/en-us/library/kxt4418a.aspx) also uses recursion to catch controls nested in different objects. Pretty neat! Thanks.



  • JAson_scoobyjw

    Shakalama,

    The ButtonArray is not a standard component, but if you click Tools -> Choose Toolbox Items you will find it listed. Click the checkbox next to ButtonArray and it will appear in your Toolbox. And, yes I'm working with the Express Edition.



  • ButtonArray