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;
}
else
{
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;
                }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.