Hide

SftTree/NET 2.0 - Tree Control for Windows Forms

Display
Print

EditAllowed Event, SftTree Class

Occurs to determine whether a cell can be reached for cell editing.

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

Syntax

public event EditAllowedEventHandler EditAllowed;
Public Event EditAllowed As EditAllowedEventHandler

Comments

Occurs to determine whether a cell can be reached for cell editing.

This event occurs while the while an SftTree.EditNavigate method is processed, to determine whether a cell can be reached during cell editing. It is possible to suppress cell editing for items and cells using the ItemClass.EditIgnore and CellClass.EditIgnore properties. In addition, the EditAllowed event can be used to disallow editing of cells, even if the cell is otherwise editable.

If cell editing is suppressed for items and cells using the ItemClass.EditIgnore and CellClass.EditIgnore properties, the EditAllowed event does not occur for these items and cells.

Other than determining whether a cell can be reached during cell editing, this event should not take any other action or update the tree control in any way.

Examples

C#

            for (int i = 0 ; i < 100 ; ++i) {
                ItemClass item = sftTree1.ItemCollection.Add(new string[] {"Can't", "Text", "Combo"} );
            }
            sftTree1.Columns.MakeOptimal(0, false);
            sftTree1.RecalcHorizontalExtent();
            sftTree1.Initializing = false;
        }

        private void sftTree1_EditAllowed(object sender, Softelvdm.SftTreeNET.EditAllowedEventArgs e) {
            Debug.Write("** EditAllowed");
            DumpValues(e);
            if (e.Cell.ColumnIndex == 0) // Can't edit the first column
                e.Allowed = false;
        }

        private void sftTree1_EditSetup(object sender, Softelvdm.SftTreeNET.EditSetupEventArgs e) {

VB.NET

        Dim item As ItemClass
        item = sftTree1.ItemCollection.Add(New String() {"Can't", "Text", "Combo"})
    Next
    sftTree1.Columns.MakeOptimal(0, False)
    sftTree1.RecalcHorizontalExtent()
    sftTree1.Initializing = False
End Sub

Private Sub sftTree1_EditAllowed(ByVal sender As Object, ByVal e As Softelvdm.SftTreeNET.EditAllowedEventArgs) Handles sftTree1.EditAllowed
    Debug.Write("** EditAllowed")
    DumpValues(e)
    If e.Cell.ColumnIndex = 0 Then ' Can't edit the first column
        e.Allowed = False
    End If
End Sub

See Also SftTree Class | Classes | SftTree/NET 2.0