Hide

SftTree/NET 2.0 - Tree Control for Windows Forms

Display
Print

CheckBoxClicked Event, SftTree Class

Occurs when a checkbox part (CheckBoxPartClass) is clicked.

Class: SftTree
Namespace: Softelvdm.SftTreeNET
Assembly: Softelvdm.SftTreeNET

Syntax

public event CheckBoxEventHandler CheckBoxClicked;
Public Event CheckBoxClicked As CheckBoxEventHandler

Comments

Occurs when a checkbox part (CheckBoxPartClass) is clicked.

Examples

C#

            if (e.KeyChar == ' ') {
                ItemClass item = sftTree1.FocusItem;
                if (item != null) {
                    GenericPartClass gp = item.Cells[0].Parts[0];
                    if (gp is CheckBoxPartClass) {
                        CheckBoxPartClass cb = (CheckBoxPartClass) gp;
                        cb.State = cb.State == CheckBoxStateEnum.Checked ? CheckBoxStateEnum.Unchecked : CheckBoxStateEnum.Checked;
                        e.Handled = true;
                        // changing the checkbox state doesn't automatically call the CheckBoxClicked event
                        CellClass owningCell = (CellClass)cb.PartOwner;
                        ItemClass owningItem = owningCell.OwningItem;
                        sftTree1_CheckBoxClicked(this, new PartEventArgs(owningItem, owningCell, null, cb));
                    } else if (gp is RadioButtonPartClass) {
                        RadioButtonPartClass rb = (RadioButtonPartClass)gp;
                        if (sftTree1.PerformClick_RadioButtonPart(rb)) {
                            e.Handled = true;

VB.NET

            If TypeOf gp Is CheckBoxPartClass Then
                Dim cb As CheckBoxPartClass = gp
                If cb.State = CheckBoxStateEnum.Checked Then
                    cb.State = CheckBoxStateEnum.Unchecked
                Else
                    cb.State = CheckBoxStateEnum.Checked
                End If
                e.Handled = True
                ' changing the checkbox state doesn't automatically call the CheckBoxClicked event
                Dim owningCell As CellClass = cb.PartOwner
                Dim owningItem As ItemClass = owningCell.OwningItem
                SftTree1_CheckBoxClicked(Me, New PartEventArgs(owningItem, owningCell, Nothing, cb))
            ElseIf TypeOf gp Is RadioButtonPartClass Then
                Dim rb As RadioButtonPartClass = gp
                If SftTree1.PerformClick_RadioButtonPart(rb) Then
                    e.Handled = True

See Also SftTree Class | Classes | SftTree/NET 2.0