Skip to main content

looping through control

  • November 16, 2016
  • 1 reply
  • 0 views

looking for a way to loop through a Form.ControlCollection in visual cobol. Any solutions?

set netInt to type System.Windows.Forms.Control ControlCollection::Count.
set gridViewIndex to 0.

perform until gridViewIndex = netInt

if controlList[gridViewIndex]::GetType = type TextBox
set type System.Windows.Forms.Form ControlCollection.Item[gridViewIndex]::ReadOnly to false
add 1 to gridViewIndex

end-perform.

compiler errors are: 

ControlCollection has no visible static member Count

type TextBox invalid operand

gridViewItem is invalid operand

1 reply

Chris Glazier
Forum|alt.badge.img+2

looking for a way to loop through a Form.ControlCollection in visual cobol. Any solutions?

set netInt to type System.Windows.Forms.Control ControlCollection::Count.
set gridViewIndex to 0.

perform until gridViewIndex = netInt

if controlList[gridViewIndex]::GetType = type TextBox
set type System.Windows.Forms.Form ControlCollection.Item[gridViewIndex]::ReadOnly to false
add 1 to gridViewIndex

end-perform.

compiler errors are: 

ControlCollection has no visible static member Count

type TextBox invalid operand

gridViewItem is invalid operand

Something like this?

      perform varying ctrl as type Control thru self::Controls
           if ctrl::GetType = type of TextBox
|                set ctrl as type TextBox::ReadOnly to false
           end-if
      end-perform.