Unable to remove focus in SelectionChanged event

4 posts, 0 answers
  1. Terry
    Terry avatar
    157 posts
    Member since:
    Jul 2009

    Posted 25 Nov 2009 Link to this post

    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  
                }  
            }  
     


  2. Terry
    Terry avatar
    157 posts
    Member since:
    Jul 2009

    Posted 25 Nov 2009 Link to this post

    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().
  3. DevCraft banner
  4. sri
    sri avatar
    21 posts
    Member since:
    Jan 2011

    Posted 02 Jun 2011 Link to this post

    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
  5. George
    Admin
    George avatar
    1332 posts

    Posted 08 Jun 2011 Link to this post

    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
Back to Top