Need to enable NumericUpDown if CheckBox is check - Getting error Non-invocable member ... cannot be used like a method

Upon form load code:

_checkBoxs = new[] { cbXLight, cbLight, cbMedium, cbHeavy, cbXHeavy, cbXXHeavy, cbXXXHeavy };
_minimumsNumericUpDowns = new[] { null, nLightMin, nMediumMin, nHeavyMin, nXHeavyMin, nXXHeavyMin, nXXXHeavyMin };
_maximumsNumericUpDowns = new[] { nXLightMax, nLightMax, nMediumMax, nHeavyMax, nXHeavyMax, nXXHeavyMax, null };

Open in new window


My method:

// Private Fields
private CheckBox[] _checkBoxs;
private NumericUpDown[] _minimumsNumericUpDowns;
private NumericUpDown[] _maximumsNumericUpDowns;

private void CheckBox_NumericState(object sender, EventArgs e)
{

    // disable everything
    DisableNumericUpDowns();

    // see if more than one checkbox is checked:
    var numChecked = _checkBoxs.Count(cb => cb.Checked);

    // enable things if more than one item is checked:
    if (numChecked <= 1) return;
    // find the smallest and enable its max:
    var smallest = -1;
    for (var i = 0; i < _checkBoxs.Length; i++)
    {
        if (!_checkBoxs(i).Checked) continue;
        if (!(_maximumsNumericUpDowns(i) == null))
        {
            _maximumsNumericUpDowns(i).Enabled = true;
        }
        smallest = i;
        break;
    }

    // find the largest and enable its min:
    var largest = -1;
    for (var i = _checkBoxs.Length - 1; i >= 0; i--)
    {
        if (_checkBoxs(i).Checked)
        {
            if (!(_minimumsNumericUpDowns(i) == null))
            {
                _minimumsNumericUpDowns(i).Enabled = true;
            }
            largest = i;
            break;
        }
    }

    // enable both for everything between smallest and largest:
    var tempVar = largest - 1;
    for (var i = (smallest + 1); i <= tempVar; i++)
    {
        if (!_checkBoxs(i).Checked) continue;
        if (!(_minimumsNumericUpDowns(i) == null))
        {
            _minimumsNumericUpDowns(i).Enabled = true;
        }
        if (!(_maximumsNumericUpDowns(i) == null))
        {
            _maximumsNumericUpDowns(i).Enabled = true;
        }
    }
}

Open in new window


Code to disable numerics:

private void DisableNumericUpDowns()
{
    // disable everything:
    foreach (var n in _minimumsNumericUpDowns)
    {
        if (n != null)
        {
            n.Enabled = false;
        }
    }
    foreach (var n in _maximumsNumericUpDowns)
    {
        if (n != null)
        {
            n.Enabled = false;
        }
    }
}

Open in new window


Error I get is:
Non-invocable member 'xxx' cannot be used like a method. The xxx is for each  _chechBoxs, _minimumsNumericUpDowns, and
_maximumsNumericUpDowns  in all the for-loops.  I don't understand what I am doing wrong.
Tim WordNetwork AdministratorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

anarki_jimbelSenior DeveloperCommented:
Use [ ], not ( ) for arrays:

_maximumsNumericUpDowns[i] .
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
p_davisCommented:
and anything that can be indexed directly
1
Tim WordNetwork AdministratorAuthor Commented:
Found that before I saw your answer, but thanks for your help!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.