lundi 27 février 2017

How to use Checked event properly?

I am trying to make app which will create excel sheets for multiple paths based on checkboxes.

Now i am trying create a method which will create files for checked CheckBoxes.

private void createFilesButton_Click(object sender, RoutedEventArgs e)
        {
            for (int index = 0; index < projektCheckBoxes.Count; ++index)
            {
                if (projektCheckBoxes[index].Checked)
                {
                    vytvorSoubor(index);
                    }
            }

My problem is that I am getting this fault:

Error CS0079 The event 'ToggleButton.Checked' can only appear on the left hand side of += or -=

I was searching through this forum so i tried IsChecked then i got this fault:

Error CS0266 Cannot implicitly convert type 'bool?' to 'bool'. An explicit conversion exists (are you missing a cast?)

So i searched again and i found answer that Checked is an event and that I should use the IsChecked property like this...

  if (projektCheckBoxes[index].IsChecked ?"It's checked" : "Not checked")

but this didn't helped me either.

Could you please give me advise what I am doing wrong and how it should be correctly?

Thx!




Aucun commentaire:

Enregistrer un commentaire