Welcome to the Xceed Community Sign in | Join | Help
Community Search  

TreeVeiw intercept/cancel event SelectedItemChanged

Sort Posts: Previous Next
  •  07-18-2008, 2:07 AM Post no. 13608

    TreeVeiw intercept/cancel event SelectedItemChanged

    in SmartTreeView is there a way to catch the event SelectedItemChanged  before it fires and cancel it? I want to cancel it so the user stays on the current node based on some conditon from an object on a different form/toolwindow that subscribes to SelectedItemChanged.

     

    Thanks,

  •  07-18-2008, 11:21 AM Post no. 13625 in reply to 13608

    Re: TreeVeiw intercept/cancel event SelectedItemChanged

    It is not possible to cancel it.  However, a possible workaround you can use is to to verify it the condition is met in the event handler , and if so, set the selected item back to what it was before the event was triggered.

    e.g.:

    private Xceed.SmartUI.Controls.TreeView.Node previousNode;

    private void Form1_Load(object sender, EventArgs e)

    {

        previousNode = ( Xceed.SmartUI.Controls.TreeView.Node )smartTreeView1.SelectedItem;

        smartTreeView1.SelectedItemChanged += new EventHandler( smartTreeView1_SelectedItemChanged );

    }

    void smartTreeView1_SelectedItemChanged( object sender, EventArgs e )

    {

        if( someCondition )

        {

            smartTreeView1.SelectedItem = previousNode;

        }

        else

        {

            previousNode = ( Xceed.SmartUI.Controls.TreeView.Node )smartTreeView1.SelectedItem;

        }

    }

    If your condition is fast to verify, it should not lag, the user should not see that the item was changed and reverted.

     


    André
    Software Developer and Tech Support
    Xceed Software Inc.
  •  07-20-2008, 3:20 PM Post no. 13642 in reply to 13625

    Re: TreeVeiw intercept/cancel event SelectedItemChanged

    thanks Andre (don't know how to make the accent on the e)
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.