src/Misc/EFTools/DesignXmlCore/VirtualTreeGrid/UI/VirtualTreeControl.cs
/// <summary>
///     Locate and select an object in this control
/// </summary>
/// <param name="startingBranch">The branch to start the search from, or null for the root branch.</param>
/// <param name="target">The object to locate</param>
/// <param name="selectStyle">The object location style (sent to IBranch.LocateObject locateStyle parameter)</param>
/// <param name="selectData">The object location data (sent to IBranch.LocateObject locateOptions parameter)</param>
/// <param name="extendFromAnchor">Use when SelectionMode is ExtendedMultiSelect. True to extend the selection from the current anchor position</param>
/// <param name="preserveSelection">Use when SelectionMode is ExtendedMultiSelect. True to maintain selected items outside the anchored range</param>
/// <param name="selectCaretAction">Use when SelectionMode is ExtendedMultiSelect. Specify how the selection state should be modified</param>
/// <returns>true if the item was selected</returns>
Locate and select an object in this control
Locate and select an object in this control
public bool SelectObject(
            IBranch startingBranch, object target, int selectStyle, int selectData, bool extendFromAnchor, bool preserveSelection,
            ModifySelectionAction selectCaretAction)
        {
            if (myTree != null)
            {
                var locateTarget = myTree.LocateObject(startingBranch, target, selectStyle, selectData);
                if (locateTarget.IsValid)
                {
                    var selectionColumn = mySelectionColumn;
                    var targetColumn = locateTarget.Column;
                    if (myColumnPermutation != null)
                    {
                        targetColumn = myColumnPermutation.GetPermutedColumn(targetColumn);
                        if (targetColumn == -1)
                        {
                            return false;
                        }
                    }
                    if (GetStyleFlag(VTCStyleFlags.MultiSelect) && ExtendSelectionToAnchors)
                    {
                        if (myTree.GetBlankExpansion(locateTarget.Row, selectionColumn, myColumnPermutation).AnchorColumn == targetColumn)
                        {
                            selectionColumn = targetColumn;
                        }
                    }
                    if (selectionColumn != targetColumn)
                    {
                        SetSelectionColumn(locateTarget.Column, false);
                    }
                    if (GetStyleFlag(VTCStyleFlags.ExtendedMultiSelect))
                    {
                        SetCurrentExtendedMultiSelectIndex(locateTarget.Row, extendFromAnchor, preserveSelection, selectCaretAction);
                    }
                    else
                    {
                        CurrentIndex = locateTarget.Row;
                    }
                    return true;
                }
            }
            return false;
        }
public bool SelectObject ( IBranch startingBranch , object target , int selectStyle , int selectData , bool extendFromAnchor , bool preserveSelection , ModifySelectionAction selectCaretAction ) { if ( myTree != null ) { var locateTarget = myTree . LocateObject ( startingBranch , target , selectStyle , selectData ) ; if ( locateTarget . IsValid ) { var selectionColumn = mySelectionColumn ; var targetColumn = locateTarget . Column ; if ( myColumnPermutation != null ) { targetColumn = myColumnPermutation . GetPermutedColumn ( targetColumn ) ; if ( targetColumn == - 1 ) { return false ; } } if ( GetStyleFlag ( VTCStyleFlags . MultiSelect ) && ExtendSelectionToAnchors ) { if ( myTree . GetBlankExpansion ( locateTarget . Row , selectionColumn , myColumnPermutation ) . AnchorColumn == targetColumn ) { selectionColumn = targetColumn ; } } if ( selectionColumn != targetColumn ) { SetSelectionColumn ( locateTarget . Column , false ) ; } if ( GetStyleFlag ( VTCStyleFlags . ExtendedMultiSelect ) ) { SetCurrentExtendedMultiSelectIndex ( locateTarget . Row , extendFromAnchor , preserveSelection , selectCaretAction ) ; } else { CurrentIndex = locateTarget . Row ; } return true ; } } return false ; }
Locate and select an object in this control
Locate and select an object in this control
// Item is not currently visible // If the target column is in the same blank expansion as the // current column then we leave the selection column alone. // Block if condition below
true if the item was selected
true if the item was selected
startingBranch
IBranch
The branch to start the search from, or null for the root branch.
The branch to start the search from or null for the root branch .
target
object
The object to locate
The object to locate
selectStyle
int
The object location style (sent to IBranch.LocateObject locateStyle parameter)
The object location style ( sent to IBranch . LocateObject locateStyle parameter )
selectData
int
The object location data (sent to IBranch.LocateObject locateOptions parameter)
The object location data ( sent to IBranch . LocateObject locateOptions parameter )
extendFromAnchor
bool
Use when SelectionMode is ExtendedMultiSelect. True to extend the selection from the current anchor position
Use when SelectionMode is ExtendedMultiSelect . True to extend the selection from the current anchor position
preserveSelection
bool
Use when SelectionMode is ExtendedMultiSelect. True to maintain selected items outside the anchored range
Use when SelectionMode is ExtendedMultiSelect . True to maintain selected items outside the anchored range
selectCaretAction
ModifySelectionAction
Use when SelectionMode is ExtendedMultiSelect. Specify how the selection state should be modified
Use when SelectionMode is ExtendedMultiSelect . Specify how the selection state should be modified