Control Arrays in VB.NET


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Page 1 of 19 12311 ... LastLast
Results 1 to 15 of 278

Thread: Control Arrays in VB.NET

  1. #1
    Gary Nelson Guest

    Control Arrays in VB.NET

    Just a question:

    Gosub was removed because it got in someones way (made for untidy code)

    Lset was removed because it wasn't "safe".

    Wend just didn't sound right.

    Why were the control arrays killed?

    Were they not properly object oriented? Were they somehow dangerous?

    I've done extensive programming in VBA (EXCEL) where control arrays are not
    available, and it is a royal pain. One of my biggest problems to port to net
    is going to be control arrays.

    Any one know the story behind this?

    Gary





  2. #2
    Rick Barnett Guest

    Re: Control Arrays in VB.NET

    "Gary Nelson" <gn@contanet.es> wrote in message
    news:3ab7632d@news.devx.com...
    > Why were the control arrays killed?
    >
    > Were they not properly object oriented? Were they somehow dangerous?


    When you have visual inheritance they're not necessary. Take a look at
    Delphi.



  3. #3
    Phil Weber Guest

    Re: Control Arrays in VB.NET

    > Why were the control arrays killed?

    Gary: It's not that they were "killed," it's that they were omitted from the
    ..NET rewrite, probably due to schedule considerations. As is the case with
    most large software projects, the .NET team had more to do than they could
    get done in the allotted time, so they had to decide what they could leave
    out in order to ship on time. Like GoSub, control arrays didn't make the
    cut.
    ---
    Phil Weber



  4. #4
    Mattias Sjögren Guest

    Re: Control Arrays in VB.NET

    Rick,

    >When you have visual inheritance they're not necessary.


    How does visual inheritance make control arrays unnecessary? I think
    they would still be darn useful.


    >Take a look at Delphi.


    I prefer not to. :-)


    Matt

    ====================================
    Mattias Sjögren - mattias @ mvps.org

  5. #5
    Patrick Troughton Guest

    Re: Control Arrays in VB.NET


    Hi Gary,

    Control arrays aren't really needed in .NET, or at least they're not as useful
    as they used to be. First, VB supports delegates so you can assign the same
    event procedure to multiple controls without using a control array. Second,
    if you want to loop controls, you can assign each control to a collection
    and just iterate on that.

    /Pat

    "Gary Nelson" <gn@contanet.es> wrote:
    >Just a question:
    >
    >Gosub was removed because it got in someones way (made for untidy code)
    >
    >Lset was removed because it wasn't "safe".
    >
    >Wend just didn't sound right.
    >
    >Why were the control arrays killed?
    >
    >Were they not properly object oriented? Were they somehow dangerous?
    >
    >I've done extensive programming in VBA (EXCEL) where control arrays are

    not
    >available, and it is a royal pain. One of my biggest problems to port to

    net
    >is going to be control arrays.
    >
    >Any one know the story behind this?
    >
    >Gary
    >
    >
    >
    >



  6. #6
    David A. Rothgery Guest

    Re: Control Arrays in VB.NET

    Phil Weber <pweber@devx.com> wrote:
    > > Why were the control arrays killed?

    >
    > Gary: It's not that they were "killed," it's that they were omitted from the
    > .NET rewrite, probably due to schedule considerations. As is the case with
    > most large software projects, the .NET team had more to do than they could
    > get done in the allotted time, so they had to decide what they could leave
    > out in order to ship on time. Like GoSub, control arrays didn't make the
    > cut.


    That, and the rather illogical differences between a Control Array and
    an array of Controls.

    --
    Dave Rothgery
    Picking nits since 1976
    drothgery@myrealbox.com
    http://drothgery.editthispage.com

  7. #7
    Matthew Solnit Guest

    Re: Control Arrays in VB.NET

    "Patrick Troughton" <Patrick@Troughton.com> wrote in message
    news:3ab77fc0$1@news.devx.com...
    > Control arrays aren't really needed in .NET, or at least they're not as useful
    > as they used to be. First, VB supports delegates so you can assign the same
    > event procedure to multiple controls without using a control array. Second,
    > if you want to loop controls, you can assign each control to a collection
    > and just iterate on that.


    Third, under WinForms it is easy to add controls at run-time (the other main use
    of control arrays).

    -- Matthew Solnit



  8. #8
    Craig Clearman Guest

    Re: Control Arrays in VB.NET

    Patrick,

    >Control arrays aren't really needed in .NET, or at least they're not as useful
    >as they used to be. First, VB supports delegates so you can assign the same
    >event procedure to multiple controls without using a control array. Second,
    >if you want to loop controls, you can assign each control to a collection
    >and just iterate on that.


    Generally, the reason control arrays are not there is because they are
    hard. MS had to triage them out of WinForms framework. If you remember
    back to VB4, MS came close to dropping control arrays at that time,
    because it was so difficult to merge the event handlers from control
    arrays and non-control arrays.

    I will miss this functionality, though.

    As you say, some of the functionality has isomorphic equivalents in
    Visual Fred, but there is still missing functionality.

    Mark Boulter provided the following list of the ways MS' customers use
    control arrays. MS had interviewed a large number of their customers.
    Furthermore, MS was able to scan through a large number of projects to
    find out how control arrays were being used. They found the following
    uses:

    1. Dynamically adding controls and dynamically handling control
    events at runtime

    2. Handling multiple events on multiple controls with a single
    event handler

    3. Allowing more than 254 (named) controls on a Form

    4. Setting multiple properties on a control at once

    5. Creating a clone of an existing control with a default set of
    properties

    6. Iterating over a collection of related controls

    7. Being able to use a Name/Index on a control instead of just a
    name.

    Some, like uses 1, 3, and 7 are very minor losses to me. Visual Fred
    doesn't have a 254 name limitation. Furthermore, it is easy to add
    controls at runtime. (However, it will still require more work than in
    VB6).

    Handling multiple events is even more laborious in Visual Fred. You
    can't get it to work without writing code, or pulling the control
    array additions. In VB6, you only had to paste the current control,
    and it would create an array for you, sharing one event. Iterating the
    collections has the exact same drawbacks. There are more steps to
    handle the same functionality, and it is less intuitively obvious how
    to handle them.

    What really bums me is the loss of the cloning capabilities. Now, when
    I add a new control, I have to hit each and every non-default
    property. I can't have it take the values from its sibling. That will
    greatly increase some of my UI code. Actually, it will probably force
    a rearchitecture, because I don't want to write that much error-prone
    code.

    Ciao, Craig


  9. #9
    Jonathan Allen Guest

    Re: Control Arrays in VB.NET

    Well, at least MS has admitted that removing them was a mistake. That may
    mean they intend to revisit in a later version. Of course that does nothing
    to help us now, but at least there is hope.

    --
    Jonathan Allen


    "Craig Clearman" <chclear@nospam.please> wrote in message
    news:bq3fbtgnsitgp69k240o2ackvn1dttpijo@4ax.com...
    > Patrick,
    >
    > >Control arrays aren't really needed in .NET, or at least they're not as

    useful
    > >as they used to be. First, VB supports delegates so you can assign the

    same
    > >event procedure to multiple controls without using a control array.

    Second,
    > >if you want to loop controls, you can assign each control to a collection
    > >and just iterate on that.

    >
    > Generally, the reason control arrays are not there is because they are
    > hard. MS had to triage them out of WinForms framework. If you remember
    > back to VB4, MS came close to dropping control arrays at that time,
    > because it was so difficult to merge the event handlers from control
    > arrays and non-control arrays.
    >
    > I will miss this functionality, though.
    >
    > As you say, some of the functionality has isomorphic equivalents in
    > Visual Fred, but there is still missing functionality.
    >
    > Mark Boulter provided the following list of the ways MS' customers use
    > control arrays. MS had interviewed a large number of their customers.
    > Furthermore, MS was able to scan through a large number of projects to
    > find out how control arrays were being used. They found the following
    > uses:
    >
    > 1. Dynamically adding controls and dynamically handling control
    > events at runtime
    >
    > 2. Handling multiple events on multiple controls with a single
    > event handler
    >
    > 3. Allowing more than 254 (named) controls on a Form
    >
    > 4. Setting multiple properties on a control at once
    >
    > 5. Creating a clone of an existing control with a default set of
    > properties
    >
    > 6. Iterating over a collection of related controls
    >
    > 7. Being able to use a Name/Index on a control instead of just a
    > name.
    >
    > Some, like uses 1, 3, and 7 are very minor losses to me. Visual Fred
    > doesn't have a 254 name limitation. Furthermore, it is easy to add
    > controls at runtime. (However, it will still require more work than in
    > VB6).
    >
    > Handling multiple events is even more laborious in Visual Fred. You
    > can't get it to work without writing code, or pulling the control
    > array additions. In VB6, you only had to paste the current control,
    > and it would create an array for you, sharing one event. Iterating the
    > collections has the exact same drawbacks. There are more steps to
    > handle the same functionality, and it is less intuitively obvious how
    > to handle them.
    >
    > What really bums me is the loss of the cloning capabilities. Now, when
    > I add a new control, I have to hit each and every non-default
    > property. I can't have it take the values from its sibling. That will
    > greatly increase some of my UI code. Actually, it will probably force
    > a rearchitecture, because I don't want to write that much error-prone
    > code.
    >
    > Ciao, Craig
    >




  10. #10
    Matthew Solnit Guest

    Re: Control Arrays in VB.NET

    "Craig Clearman" <chclear@nospam.please> wrote in message
    news:bq3fbtgnsitgp69k240o2ackvn1dttpijo@4ax.com...
    > What really bums me is the loss of the cloning capabilities. Now, when
    > I add a new control, I have to hit each and every non-default
    > property. I can't have it take the values from its sibling. That will
    > greatly increase some of my UI code. Actually, it will probably force
    > a rearchitecture, because I don't want to write that much error-prone
    > code.


    You can create a UserControl which inherits from the base control, and has all
    the same functionality but with preset values for those properties. Since
    VB.NET supports inheritance, you can extend existing controls +much+ more easily
    than in VB5-6.

    The more I learn about .NET, the more I see that the way to get things done is
    not to mimic older methodologies, but to learn the new ones.

    -- Matthew Solnit



  11. #11
    Craig Clearman Guest

    Re: Control Arrays in VB.NET

    Matthew,

    >You can create a UserControl which inherits from the base control, and has all
    >the same functionality but with preset values for those properties. Since
    >VB.NET supports inheritance, you can extend existing controls +much+ more easily
    >than in VB5-6.


    That's the rearchitecture I was intimating.

    Really, though, I'm not very happy with the idea, because it starts to
    push an inheritance tree deeper than I'd like. I don't want to end up
    with a support hassle of training someone for a deep hierarchy.

    Ciao, Craig


  12. #12
    Craig Clearman Guest

    Re: Control Arrays in VB.NET

    Jonathan,

    >Well, at least MS has admitted that removing them was a mistake.


    Not at all.

    Mark made the list. I made the commentary; and nowhere did I use a
    word like 'mistake.' There was no mistake. It was a conscious,
    informed, decision. I might not like the outcome, but that's not the
    same thing.

    Ciao, Craig


  13. #13
    Jonathan Allen Guest

    Re: Control Arrays in VB.NET

    Regardless of what you and Mark may think about the issue, someone MS has
    admitted that not having control arrays was a mistake that they intend to
    rectify at some point in the future. They stated that during the VB MVP
    Summit in March when they announced that the Tag and Name properties were
    being added.

    --
    Jonathan Allen


    "Craig Clearman" <chclear@nospam.please> wrote in message
    news:u69fbtgj21l3t1d0s47s859tqiebk7vhq5@4ax.com...
    > Jonathan,
    >
    > >Well, at least MS has admitted that removing them was a mistake.

    >
    > Not at all.
    >
    > Mark made the list. I made the commentary; and nowhere did I use a
    > word like 'mistake.' There was no mistake. It was a conscious,
    > informed, decision. I might not like the outcome, but that's not the
    > same thing.
    >
    > Ciao, Craig
    >




  14. #14
    Patrick Troughton Guest

    Re: Control Arrays in VB.NET


    Tag? Ugh. If you need to add an additional property to an existing control,
    there's already a better way to do it....inheritance. Hopefully, they'll
    reconsider this one. Regardless, any other changes we can expect?

    /Pat

    "Jonathan Allen" <greywolf@cts.com> wrote:
    >Regardless of what you and Mark may think about the issue, someone MS has
    >admitted that not having control arrays was a mistake that they intend to
    >rectify at some point in the future. They stated that during the VB MVP
    >Summit in March when they announced that the Tag and Name properties were
    >being added.
    >
    >--
    >Jonathan Allen


  15. #15
    Jonathan Allen Guest

    Re: Control Arrays in VB.NET

    > Ugh. If you need to add an additional property to an existing control,
    > there's already a better way to do it....inheritance.


    For experienced programmers, yes. But there needs to be a way to do things
    without inheritance for the sake of novices. Besides, at only 32-bits, it is
    not like Tag is a significant drain on resources.

    > Regardless, any other changes we can expect?


    Yes, but there is no list and I can't remember all the ones I have heard
    about. However, if there is a specific feature you are interested in someone
    may know a thing or two about it.

    --
    Jonathan Allen


    "Patrick Troughton" <NoSpam@NoSpam.com> wrote in message
    news:3ab7af9e$1@news.devx.com...
    >
    > Tag? Ugh. If you need to add an additional property to an existing

    control,
    > there's already a better way to do it....inheritance. Hopefully, they'll
    > reconsider this one. Regardless, any other changes we can expect?
    >
    > /Pat
    >
    > "Jonathan Allen" <greywolf@cts.com> wrote:
    > >Regardless of what you and Mark may think about the issue, someone MS has
    > >admitted that not having control arrays was a mistake that they intend to
    > >rectify at some point in the future. They stated that during the VB MVP
    > >Summit in March when they announced that the Tag and Name properties were
    > >being added.
    > >
    > >--
    > >Jonathan Allen




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center