Hi,
I have a RadCombobox with following properties:
IsEditable="True"
OpenDropDownOnFocus="False"
TextSearchMode="Contains"
IsFilteringEnabled="True"
UpdateTextOnLostFocus="False"
CanAutocompleteSelectItems="False"
IsReadOnly="False"
And when user types, I open the dropdown with following code:
comboBox.IsDropDownOpen = true;
my problem is:
when a user wants to insert some words in exist text, whole text will be clear.
what I can do to solve this.
My project:
http://www.mediafire.com/file/2ru22za4ztsuas4/ComboBoxEditModeProj.rar
Thanks.
I have a RadCombobox with following properties:
IsEditable="True"
OpenDropDownOnFocus="False"
TextSearchMode="Contains"
IsFilteringEnabled="True"
UpdateTextOnLostFocus="False"
CanAutocompleteSelectItems="False"
IsReadOnly="False"
And when user types, I open the dropdown with following code:
comboBox.IsDropDownOpen = true;
my problem is:
when a user wants to insert some words in exist text, whole text will be clear.
what I can do to solve this.
My project:
http://www.mediafire.com/file/2ru22za4ztsuas4/ComboBoxEditModeProj.rar
Thanks.
8 Answers, 1 is accepted
0
Hi Ahmad,
You can try changing the logic of opening the DropDown to execute after the text is already entered. For example, in the Loaded event of the control:
It seems to work in the sample you have provided. Please give it a try.
Regards,
Stefan Nenchev
Telerik by Progress
You can try changing the logic of opening the DropDown to execute after the text is already entered. For example, in the Loaded event of the control:
private
void
comboBox_Loaded(
object
sender, RoutedEventArgs e)
{
(sender
as
RadComboBox).ChildrenOfType<TextBox>().FirstOrDefault().TextChanged += MainWindow_TextChanged;
}
private
void
MainWindow_TextChanged(
object
sender, TextChangedEventArgs e)
{
if
(!
this
.comboBox.IsDropDownOpen)
this
.comboBox.IsDropDownOpen =
true
;
}
It seems to work in the sample you have provided. Please give it a try.
Regards,
Stefan Nenchev
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Ahmad
Top achievements
Rank 1
answered on 05 Apr 2017, 04:55 AM
Hi Stefan,
thanks for
I used your solution but it makes another problem:
when I insert a word, whole text will select and I can't type another word after that.
thanks for
I used your solution but it makes another problem:
when I insert a word, whole text will select and I can't type another word after that.
0
Hello,
You can try saving the caretPosition and set it when the DropDown is Opened:
Regards,
Stefan Nenchev
Telerik by Progress
You can try saving the caretPosition and set it when the DropDown is Opened:
int
caretPosition;
private
void
MainWindow_TextChanged(
object
sender, TextChangedEventArgs e)
{
caretPosition = (sender
as
TextBox).CaretIndex;
if
(!
this
.comboBox.IsDropDownOpen)
this
.comboBox.IsDropDownOpen =
true
;
}
private
void
comboBox_DropDownOpened(
object
sender, EventArgs e)
{
(sender
as
RadComboBox).ChildrenOfType<TextBox>().FirstOrDefault().CaretIndex = caretPosition;
caretPosition = 0;
}
Regards,
Stefan Nenchev
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
0
Ahmad
Top achievements
Rank 1
answered on 08 Apr 2017, 09:49 AM
Hi Stefan,
thanks
It was helpful,
but it is useless when user wanna select a substring and change that.
there is any way for that?
thanks
It was helpful,
but it is useless when user wanna select a substring and change that.
there is any way for that?
0
Hi Ahmad,
Modifying a substring works fine for me. Please provide steps to reproduce the undesired behavior. I have attached the modified sample.
Regards,
Stefan Nenchev
Telerik by Progress
Modifying a substring works fine for me. Please provide steps to reproduce the undesired behavior. I have attached the modified sample.
Regards,
Stefan Nenchev
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
0
Ahmad
Top achievements
Rank 1
answered on 19 Apr 2017, 01:45 PM
Hi,
there is an issue:
I set IsReadOnly to True.
when I wanna type a word, the first letter will be ignored.
how I fixed that?
there is an issue:
I set IsReadOnly to True.
when I wanna type a word, the first letter will be ignored.
how I fixed that?
0
Hello Ahmad,
I am not sure what you mean as when you set the RadComboBox as ReadOnly - you should not be able to type in any letters. What do you mean by "the first letter will be ignored"? It seems that after the custom logic we have introduced, in some cases, it is possible to type in letters even though the control is in ReadOnly mode. Please try subscribing to the PreviewKeyDown event and do the following:
Regards,
Stefan Nenchev
Telerik by Progress
I am not sure what you mean as when you set the RadComboBox as ReadOnly - you should not be able to type in any letters. What do you mean by "the first letter will be ignored"? It seems that after the custom logic we have introduced, in some cases, it is possible to type in letters even though the control is in ReadOnly mode. Please try subscribing to the PreviewKeyDown event and do the following:
private
void
comboBox_PreviewKeyDown(
object
sender, KeyEventArgs e)
{
var comboBox = sender
as
RadComboBox;
if
(comboBox !=
null
&& comboBox.IsReadOnly ==
true
)
{
e.Handled =
true
;
}
}
Regards,
Stefan Nenchev
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
0
Ahmad
Top achievements
Rank 1
answered on 26 Apr 2017, 05:15 AM
Hello Stefan,
with follwing config:
IsEditable="True"
OpenDropDownOnFocus="False"
TextSearchMode="Contains"
IsFilteringEnabled="True"
UpdateTextOnLostFocus="False"
CanAutocompleteSelectItems="False"
IsReadOnly="True"
in your solution, we can't type. but I wanna be able of typing.
it is my scenario:
assume I wanna type "Alex"
I type "A" ComboBox.Text will be "A"
but when I type "l"
ComboBox.Tex will be "l" instead of "Al"
and there is another problem:
I can't change a substring in this mode(IsReadOnly="True").
Thanks.
with follwing config:
IsEditable="True"
OpenDropDownOnFocus="False"
TextSearchMode="Contains"
IsFilteringEnabled="True"
UpdateTextOnLostFocus="False"
CanAutocompleteSelectItems="False"
IsReadOnly="True"
in your solution, we can't type. but I wanna be able of typing.
it is my scenario:
assume I wanna type "Alex"
I type "A" ComboBox.Text will be "A"
but when I type "l"
ComboBox.Tex will be "l" instead of "Al"
and there is another problem:
I can't change a substring in this mode(IsReadOnly="True").
Thanks.