Link to home
Start Free TrialLog in
Avatar of Sheritlw
SheritlwFlag for United States of America

asked on

Using For Each VB 2008

I am trying to loop through a form that has multiple splitcontainers, comboboxes and grids (FPSpread).

I only want to loop through the grids.

How do  I do this?

Dim cnt As FarPoint.Win.Spread.FpSpread

        For Each cnt In Me.Controls

Thanks
Avatar of djon2003
djon2003
Flag of Canada image

In the For each loop.. check for the type of control you have..

So :
Dim cnt As Control

For Each cnt In Me.Controls
If TypeOf cnt Is FarPoint.Win.Spread.FpSpread Then
'' DO SOMETHING
End If
Next Each
Avatar of Sheritlw

ASKER

I have probably 30  grids on  the form.  I need to get  the controls name, activesheet, etc.. while looping through so I need to reference the control type as a spread so I don't get errors when trying  to loop through them.
The grid has different properties etc. than regular controls.
thanks
Just cast the control found to your class type..

Dim cnt As Control

For Each cnt In Me.Controls
If TypeOf cnt Is FarPoint.Win.Spread.FpSpread Then
   Dim curGrid As FarPoint.Win.Spread.FpSpread = cnt
'' DO SOMETHING
End If
Next Each
Unfortunetly it's  not finding  the grids.  I think it's because my form has a tabcontrol  with multiple tabs and a SplitContainer.  All the grids are on the  splitcontainers.
How do  I reference all the splitcontainers  and grids?
Thanks
ASKER CERTIFIED SOLUTION
Avatar of djon2003
djon2003
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial