|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Upgrade QuestionI am rewriting a VB6 program from scratch. In vb6 I had an index
commandbtton and was able to do use a for loop to make changes to the entire group of button. For example the following code worked out ok Dim i As Integer For i = 0 To cmdButtn.Count - 1 With cmdButtn(i) .ToolTipText = .Caption End With Next i As per every other programmer I am trying not to use the upgrade wizard. Is there an easy way to translate this in vb.net Jos***@aol.com wrote:
Show quoteHide quote > I am rewriting a VB6 program from scratch. In vb6 I had an index Here is one possible anser:> commandbtton and was able to do use a for loop to make changes to the > entire group of button. For example the following code worked out ok > > > Dim i As Integer > For i = 0 To cmdButtn.Count - 1 > With cmdButtn(i) > .ToolTipText = .Caption > End With > Next i > > > As per every other programmer I am trying not to use the upgrade > wizard. Is there an easy way to translate this in vb.net http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchcreatingcontrolarraysinvisualbasicnetvisualcnet.asp The other is just to stick the buttons in an actuall array or a Generic List (if you using 2005) and then you can iterate the list: for each btn in buttonList btn.text = "hi" next HTH, -- Tom Shelton Jos***@aol.com wrote:
Show quoteHide quote > I am rewriting a VB6 program from scratch. In vb6 I had an index I don't think you would call this "easy", but you might *manually* put> commandbtton and was able to do use a for loop to make changes to the > entire group of button. For example the following code worked out ok > > > Dim i As Integer > For i = 0 To cmdButtn.Count - 1 > With cmdButtn(i) > .ToolTipText = .Caption > End With > Next i > > > As per every other programmer I am trying not to use the upgrade > wizard. Is there an easy way to translate this in vb.net the buttons in an array... <aircode> 'at Form scope private mButtons() As Button = { _ cmdButton01, cmdButton02, cmdButton3, ..., cmdButtonN _ } 'Somewhere else in code For Each B as Button In mButtons B.ToolTipText = B.Caption Next </aircode> HTH. Regards, Branco. Control arrays have gone away. (Bummer, I used them, too.)
If you want to hit all the buttons on a form, you could do the following. This sets the tooltiptext equal to the caption on the button. The [caption] property has been replaced by the [text] property. This is recursive so if you have panels on your form or some other kind of container, it checks the controls in that container as well. Private Sub SetButtonText(ByVal ctrlContainer As Control) For Each ctrl As Control In ctrlContainer.Controls If TypeOf ctrl Is Button Then ctrl.ToolTipText = ctrl.Text End If 'if control has children, call this function recursively If ctrl.HasChildren Then SetButtonText(ctrl) End If Next End Sub Robin S. ------------------- <Jos***@aol.com> wrote in message Show quoteHide quote news:s1kbm294cgpm8qesnfiluuch7ek8kcrfb1@4ax.com... >I am rewriting a VB6 program from scratch. In vb6 I had an index > commandbtton and was able to do use a for loop to make changes to the > entire group of button. For example the following code worked out ok > > > Dim i As Integer > For i = 0 To cmdButtn.Count - 1 > With cmdButtn(i) > .ToolTipText = .Caption > End With > Next i > > > As per every other programmer I am trying not to use the upgrade > wizard. Is there an easy way to translate this in vb.net <Jos***@aol.com> schrieb:
>I am rewriting a VB6 program from scratch. In vb6 I had an index Accessing controls by their names or indices> commandbtton and was able to do use a for loop to make changes to the > entire group of button. <URL:http://dotnet.mvps.org/dotnet/faqs/?id=controlbynameindex&lang=en> -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/> Joseph
\\\ dim cmdButtn() as control = {Mybutton1, Mybutton2, MyMoreButton4} For i as integer = 0 To cmdButtn.Count - 1 cmd(i).ToolTipText = cmd(i).Text Next /// I hope this helps, Cor Thanks for the replys. Can some explain why they were dropped?
On Fri, 24 Nov 2006 06:46:18 +0100, "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote: Show quoteHide quote >Joseph > >\\\ >dim cmdButtn() as control = {Mybutton1, Mybutton2, MyMoreButton4} >For i as integer = 0 To cmdButtn.Count - 1 > cmd(i).ToolTipText = cmd(i).Text >Next >/// > >I hope this helps, > >Cor > Jos***@aol.com wrote:
> Thanks for the replys. Can some explain why they were dropped? I'm not sure anyone knows the answer to that except MS :) But, I will> say this, that it is one of the few features I miss. There are lots of other ways to get around it - but all of them require manual intervention because the designer has no support for control arrays. Maybe VB.NET 2008? -- Tom Shelton Joseph,
As I showed they are not dropped, every control has now its own control collection as the form has too. However the way they could be set in VB6 was in fact a little bit clumsy, it was something special made only for forms. Cor <Jos***@aol.com> schreef in bericht Show quoteHide quote news:890em2d3hhflktik2ml7249c1p38t37rtq@4ax.com... > Thanks for the replys. Can some explain why they were dropped? > > > On Fri, 24 Nov 2006 06:46:18 +0100, "Cor Ligthert [MVP]" > <notmyfirstn***@planet.nl> wrote: > >>Joseph >> >>\\\ >>dim cmdButtn() as control = {Mybutton1, Mybutton2, MyMoreButton4} >>For i as integer = 0 To cmdButtn.Count - 1 >> cmd(i).ToolTipText = cmd(i).Text >>Next >>/// >> >>I hope this helps, >> >>Cor >> > "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schrieb: Well, would it really be a problem to provide support for control arrays in > As I showed they are not dropped, every control has now its own control > collection as the form has too. the designer in addition to the features currently provided? I don't think so. > However the way they could be set in VB6 was in fact a little bit clumsy, I don't think it was clumsy, it was simply VB6's way. With some > it was something special made only for forms. improvements I'd like to see a replacement in .NET too. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/> Herfried K. Wagner [MVP] wrote:
Show quoteHide quote > "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schrieb: I fully agree with you Herfied. This was a nice feature of VB.CLASSIC,> > As I showed they are not dropped, every control has now its own control > > collection as the form has too. > > Well, would it really be a problem to provide support for control arrays in > the designer in addition to the features currently provided? I don't think > so. > > > However the way they could be set in VB6 was in fact a little bit clumsy, > > it was something special made only for forms. > > I don't think it was clumsy, it was simply VB6's way. With some > improvements I'd like to see a replacement in .NET too. > that I would love to see implemented in .NET. -- Tom Shelton Tom,
You both don't need my opion in this I assume? :-) CorShow quoteHide quote "Tom Shelton" <tom_shel***@comcast.net> schreef in bericht news:1164411212.982769.54380@45g2000cws.googlegroups.com... > > Herfried K. Wagner [MVP] wrote: >> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schrieb: >> > As I showed they are not dropped, every control has now its own control >> > collection as the form has too. >> >> Well, would it really be a problem to provide support for control arrays >> in >> the designer in addition to the features currently provided? I don't >> think >> so. >> >> > However the way they could be set in VB6 was in fact a little bit >> > clumsy, >> > it was something special made only for forms. >> >> I don't think it was clumsy, it was simply VB6's way. With some >> improvements I'd like to see a replacement in .NET too. >> > > I fully agree with you Herfied. This was a nice feature of VB.CLASSIC, > that I would love to see implemented in .NET. > > -- > Tom Shelton > Cor Ligthert [MVP] wrote:
> Tom, All opinions are welcome - as long as they are the same as mine :)> > You both don't need my opion in this I assume? > > :-) > > Cor -- Tom Shelton
Q: Regular Expressions?
tell more about .net framework date time picker and validate event ( is this a bug ? ) Drag and drop multiple button controls..need help modifying code please??? Managing without .NET for runtime applications Automatic Form Fill in SQL connection problem Inherited handler problem. Looking For Training Recommendations Adapter Update...Syntax error |
|||||||||||||||||||||||