Re: Iterating controls gives stackoverflow

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Bill Borg (BillBorg_at_discussions.microsoft.com)
Date: 09/09/04


Date: Thu, 9 Sep 2004 10:43:02 -0700

Too bad intellisense can't always save me from myself...thanks much for the
fast reply.

Bill

"Karl" wrote:

> You are looping over Me.Controls over and over again, you want to do:
>
> For each ctl as Control in CC
>
> Karl
>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/
>
>
> "Bill Borg" <BillBorg@discussions.microsoft.com> wrote in message
> news:F109BBEE-1E5C-4B07-9E2D-871A7E233AED@microsoft.com...
> > Hello all,
> >
> > Below is the code (vb) for a routine that's meant to loop through a
> > collection of controls, find the textboxes, and trim the whitespace (sub
> > TrimText not shown). I expect to pass it a page, and have it iterate
> through
> > the controls on that page, and on any user controls, etc. What happens is
> > that the first time TrimAllFields is called from within the function, I
> get a
> > stackoverflow. Am I missing something simple here? Or, is there an easier
> way
> > to trim whitespace from controls?
> >
> > Thanks,
> >
> > Bill Borg
> >
> > ' ------------------------------------------
> > ' Class: TSPage
> > ' Method: TrimAllFields(CC as ControlCollection)
> > ' Description: Trim whitespace from all controls in the collection.
> > ' This routine is meant to be run recursively to iterate
> > ' all controls in the collection.
> > ' ------------------------------------------
> > Public Sub TrimAllFields(ByVal CC As ControlCollection)
> >
> > For Each ctl As Control In Me.Controls
> > ' Trim the textbox
> > If TypeOf (ctl) Is TextBox Then
> > TrimText(CType(ctl, TextBox))
> > End If
> >
> > ' Need to go deeper?
> > If ctl.HasControls Then
> > TrimAllFields(ctl.Controls)
> > End If
> > Next
> > End Sub
> >
>
>
>



Relevant Pages

  • Re: WPF LinqToSql ComboBox Master Detail
    ... I'm trying to find an example and/or advice on how to setup the bindings on basic WPF controls like ComboBox and TextBox that will get their data from LinqToSql. ... I'd like to do something like use a ComboBox as a record selector and display/edit in TextBox'es other data from the selected master record as well as a detail from a linked record in another table. ... Then you're going to go into a foreach loop, creating a new Bill each time in the loop populating Bill and adding Bill to a List. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: passing enumeration parameter to generic (all enumeration) sub
    ... Thanks Bill and Chris for the help. ... Unfortunately, 'Option Explicit Off' doesn't ... underlying enum data type is that there could be many different enum data types used. ... Virtually all controls have properties that use enums. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: passing enumeration parameter to generic (all enumeration) sub
    ... Thanks Bill and Chris for the help. ... Unfortunately, 'Option Explicit Off' doesn't ... underlying enum data type is that there could be many different enum data types used. ... Virtually all controls have properties that use enums. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Need to reset Check Box ID number
    ... "Bill D." ... > When the checkbox is clicked A1 shows check box 77 NOT MyCheckBox ... > How does Excel know for this particular sheet this is the 77th control ... All of the previous controls have been deleted by the way. ...
    (microsoft.public.excel.programming)
  • Re: do nice guys depress fitness
    ... > Bill Morse ... of governmental ability at one time to monitor and exercise controls ... In fact Pip's lack of quality of life and the ...
    (sci.bio.evolution)