I am trying to update 64 bit displays in a For Next Loop.
I can pass One Object successfully but can't iterate through a collection in order.
Shouldn't GetNextControl do this?
It Retrieves the next control forward or back in the tab order of child controls.
Is there a Better method to do this?

fn70DiscreteIO statusIO = new fn70DiscreteIO();
for (int i = 0; i <= 64; i++)
UpdateIO(statusIO.DiscreteValue, i, 
GroupBox.GetNextControl(System.Windows.Forms.ProgressBar ctrl, bool forward)); 

private void UpdateIO(int data, int bit, System.Windows.Forms.ProgressBar textControl)
if ((data & (1 << bit)) != 0)
textControl.Value = 1;
textControl.Value = 0;

Thanks for the reply. I happen to know how many controls are in my Panel so the following code worked once I casted them properly. GetNextControl is exactly what I ended up using.

Control Ctrl1 = F0;
                Button CtrlBtn = (Button)Ctrl1;
                for (int i = 0; i <= 23; i++)
                    CtrlBtn.Text = i.ToString();
                    UpdateIOForceOn(statusIO.DiscreteForceOn , i, CtrlBtn); // Update Bit Values
                    UpdateIOForceOff(statusIO.DiscreteForceOff , i, CtrlBtn); // Update I/O Type
                    Ctrl1 = groupBox3.GetNextControl(Ctrl1, true);
                    CtrlBtn = (Button)Ctrl1;
This article has been dead for over six months. Start a new discussion instead.