jeudi 24 mars 2016

Using a Treeview with Checkboxes

I have treeView that has several Nodes like this

Question 1
Question 2
Question 3
Question 4

Inside each of those node there are 4 checkboxes - Answer A, Answer B, Answer C, Answer D, depending on whichever checkbox is clicked the text of a Node will change to Question1 - A,B,C,D. The answer to the question could mean all,one,two,three or none of the checkboxes are clicked. What im trying to do is remove the letter if a checkbox is unchecked My Code:

private void ckbAnswerA_CheckedChanged(object sender, EventArgs e)
    {

        updateAnswerA();
    }
void updateAnswerA()
    {
        var words = new List<string>();


        if (ckbOption1.Checked)
        {
            words.Add("A,");
            treeView1.SelectedNode.Text += string.Join(" ", words);
        }

Etc for the other checkBoxes...

The Code above works fine when selecting a checkBoxes but not when deselecting




Aucun commentaire:

Enregistrer un commentaire