This is a migrated thread and some comments may be shown as answers.

RadContextMenu on Rightclick for autocompletebox

2 Answers 29 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Abhi
Top achievements
Rank 1
Abhi asked on 10 Jan 2013, 07:15 AM

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 Answers, 1 is accepted

Sort by
0
Rosen Vladimirov
Telerik team
answered on 10 Jan 2013, 11:02 AM
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.

0
Abhi
Top achievements
Rank 1
answered on 10 Jan 2013, 12:33 PM
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)....................
Tags
Menu
Asked by
Abhi
Top achievements
Rank 1
Answers by
Rosen Vladimirov
Telerik team
Abhi
Top achievements
Rank 1
Share this question
or