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

Unable to remove focus in SelectionChanged event

3 Answers 199 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Terry
Top achievements
Rank 1
Terry asked on 25 Nov 2009, 10:22 PM
Hi:

I have a radcombobox (cboSpecialty) and below it a ListBox.  When I select a specialty, the physicians with that specialty (and a picture) appear in the ListBox, where I automatically select the first one.  When I click on a physician in the listbox, his/her detailed bio appears.  When I hit up-arrow or down-arrow, I navigate to a different physician bio.  That all works great.

The problem is that even thoughI have selected the first item in the listbox, the combobox retains focus.  When the user wants to view the next physician, he/she hits the down-arrow.  But instead of changing the selection in the listbox, the combobox is moved to the next specialty and all of the physicians in the listbox change.

I thought the simple solution was to change the focus to the listbox inside the SelectionChanged event, but it doesn't work.  The focus remains on the combobox.

I don't know if this is a radcombobox issue or a silverlight issue.  If I could just disable keyboard input to the combobox, I'd be OK with that.  Can you help?  The code is below.  The Focus() call isn't working.

        private void cboSpecialty_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e)  
        {  
            if( cboSpecialty.SelectedValue.Equals( "<All Physicians>" ) )  
            {  
                lstName.ItemsSource = from p in pdc.Physicians   
                                      orderby p.LastName, p.FirstName, p.MiddleName   
                                      select p;  
            }  
            else 
            {  
                lstName.ItemsSource = from p in pdc.Physicians  
                                      where p.Specialties.Any( x => x.Specialty == cboSpecialty.SelectedValue.ToString() )  
                                      select p;  
            }  
 
            if (lstName.Items.Count > 0)  
            {  
                lstName.SelectedIndex = 0;  
                lstName.Focus();        // remove focus from cboSpecialty so it won't change value on down-arrow  
            }  
        }  
 


3 Answers, 1 is accepted

Sort by
0
Terry
Top achievements
Rank 1
answered on 26 Nov 2009, 01:24 AM
I figured it out.  You need to do an UpdateLayout on the listbox in order for the Focus() call to work.  The same is true for ScrollIntoView().
0
sri
Top achievements
Rank 1
answered on 02 Jun 2011, 12:40 PM
Hi,

I am also facing almost the same problem.i have a combobox and data grid but the focus will be always on the combo box when am working with grid selection changed event.
arrow keys for data grid are not working due to focus on combo box.
could you please let me know how can i remove focus on combo box?

Regards
Sridhar S
0
George
Telerik team
answered on 08 Jun 2011, 08:59 AM
Hello,

 
Could you please give us more information about your scenario? Which RadControls do you use? Also, if you send us a demo that illustrates the issue, it would be very helpful.

I am glad to assist you further.

All the best,
George
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
ComboBox
Asked by
Terry
Top achievements
Rank 1
Answers by
Terry
Top achievements
Rank 1
sri
Top achievements
Rank 1
George
Telerik team
Share this question
or