RadContextMenu on Rightclick for autocompletebox

3 posts, 0 answers
  1. Abhi
    Abhi avatar
    38 posts
    Member since:
    Nov 2012

    Posted 10 Jan 2013 Link to this post

    AutoCompleteBox t = new AutoCompleteBox();
    TextBox textbox = new TextBox();

    t = this as AutoCompleteBox;

    if (string.IsNullOrEmpty(textbox.SelectedText))

    {

     _cut.IsEnabled = false;

    _copy.IsEnabled = false;

    }

     I am Implementing RadcontextMenu for autocompletebox in base class for cut, copy paste functionalities....
    In order to get the selected text inside the autocompletebox I just used

    textbox = VisualTreeHelper.GetChild(VisualTreeHelper.GetChild(t, 0), 0) as TextBox;

    while debugging I observed that it returns the null value for the textbox, and I got the exception (object reference not set to an instance of an object) in the nextline..

    textbox.SelectedText gives that exception

    if (string.IsNullOrEmpty(textbox.SelectedText))

    {

    _cut.IsEnabled = false;
    _copy.IsEnabled = false;
    }


    please give solution for this..........

  2. Rosen Vladimirov
    Admin
    Rosen Vladimirov avatar
    640 posts

    Posted 10 Jan 2013 Link to this post

    Hi Abhi,

    You can find my answer in your other forum thread.

    All the best,
    Rosen Vladimirov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Abhi
    Abhi avatar
    38 posts
    Member since:
    Nov 2012

    Posted 10 Jan 2013 Link to this post

    Hi,

     On Rightclick on silverlight autocompletebox, I displayed RadContextMenu with cut, copy and paste functionalities, if I select some part of the text inside the autocompletebox and if I Rightclick on it, then SelectedText is visible no issues.............but if  I'll  not select anything in the autocompletebox and then if I rightclick, then SelectedText is visible with all the Text in the autocompleteBox is selected (but I didn't select anything inside the autocompletebox)....................
Back to Top