From: johnb on 10 Apr 2010 11:53 Hi All What is the code to loop thru all textbox controls on a form? TIA johnb
From: PvdG42 on 10 Apr 2010 12:29 "johnb" <johnb(a)discussions.microsoft.com> wrote in message news:A2474CF4-69FB-4320-B080-CD45BDE16757(a)microsoft.com... > Hi All > What is the code to loop thru all textbox controls on a form? > > TIA > johnb The Form class (which derives from Control) has a Controls property: http://msdn.microsoft.com/en-us/library/system.windows.forms.control.controls.aspx which is a collection of type Control. The Control class has a GetType() method to allow you to determine if the current control is a TextBox. http://msdn.microsoft.com/en-us/library/system.object.gettype(v=VS.90).aspx
From: Armin Zingler on 10 Apr 2010 12:18 Am 10.04.2010 17:53, schrieb johnb: > Hi All > What is the code to loop thru all textbox controls on a form? Inside the Form itself only or also inside other containers on the Form? The former (it's shorter ;-) ): 'assuming option infer on for each c in controls if typeof c is textbox then with directcast(c, textbox) .property = value end with end if next -- Armin
From: Cor Ligthert[MVP] on 10 Apr 2010 13:24 Peter, I've seen that the getType is currently more popular, but why not the way we here in this newsgroup has done it forever. If Typeof object Is Classname? http://www.vb-tips.com/ControlBorder.aspx Is this a kind of verCSharping (I don't know if you knows a tiny little bit Dutch, then you understand it) It means something as: using C# ways, where there is a very good VB alternative. :-) Cor "PvdG42" <pvdg42(a)toadstool.edu> wrote in message news:OIbe1rM2KHA.1016(a)TK2MSFTNGP02.phx.gbl... > > "johnb" <johnb(a)discussions.microsoft.com> wrote in message > news:A2474CF4-69FB-4320-B080-CD45BDE16757(a)microsoft.com... >> Hi All >> What is the code to loop thru all textbox controls on a form? >> >> TIA >> johnb > > The Form class (which derives from Control) has a Controls property: > > http://msdn.microsoft.com/en-us/library/system.windows.forms.control.controls.aspx > > which is a collection of type Control. > > The Control class has a GetType() method to allow you to determine if the > current control is a TextBox. > > http://msdn.microsoft.com/en-us/library/system.object.gettype(v=VS.90).aspx > > >
From: PvdG42 on 10 Apr 2010 21:39 "Cor Ligthert[MVP]" <Notmyfirstname(a)planet.nl> wrote in message news:#0gPtKN2KHA.4752(a)TK2MSFTNGP02.phx.gbl... > Peter, > > I've seen that the getType is currently more popular, but why not the way > we here in this newsgroup has done it forever. > > If Typeof object Is Classname? > > http://www.vb-tips.com/ControlBorder.aspx > > Is this a kind of verCSharping (I don't know if you knows a tiny little > bit Dutch, then you understand it) > > It means something as: using C# ways, where there is a very good VB > alternative. > > :-) > > Cor > I'm not trying to start anything, just trying to offer the OP a way the "learn to fish". Your way is certainly just as good, and certainly more VB-traditional.
|
Next
|
Last
Pages: 1 2 Prev: Event of changing the grid-cell value. Next: DotNet error message : on which statement ? |