Вопрос

I have a tab page program, where I can select multiple check box items from each tab. I want to be able to create a list where it can show me the items i have selected. Below is my attempt at the beginning of a boo lean statement, however I'm stuck. Any suggestions on how to complete this would be amazing!

public bool itemchecked
{
    get 
    { 
        return checkBox.Checked; 
    }
}
Это было полезно?

Решение

First: Add all you checkboxes to a List<CheckBox>.

Then your property could be sth. like

    public bool itemchecked
    {
        get
        { 
            var checkedBoxes = new List<CheckBox>();

            foreach(var item in AllCheckBoxes)
            {
                if(item.Checked)
                {
                   checkedBoxes.Add(item);
                }
            }

            return checkedBoxes;
        }
    }

You could also use a linQ-Expression to return the list.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top