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

[Solved] Set Cell Focus Programatically With Keyboard Support

6 Answers 136 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Josh
Top achievements
Rank 1
Josh asked on 05 Aug 2011, 08:27 PM
I'm trying to set the focus of a cell, but it doesn't seem to be working. I want to be able to have the cell focused exactly like if you were to click the cell with your mouse.

I've gone through a few different examples and none of them have worked. I'm able to get the cell to highlight, but the keyboard focus is never on the cell, or in the grid for that matter.

http://www.telerik.com/help/silverlight/gridview-how-to-set-current-cell.html
http://www.telerik.com/community/forums/silverlight/gridview/focusing-item-in-radgridview.aspx
http://www.telerik.com/community/forums/silverlight/gridview/how-to-set-focus-on-given-cell.aspx

6 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 08 Aug 2011, 02:13 PM
Hi Josh,

The information that you have found is just what you are looking for. 

The reason why you cannot actually focus the GridViewCell is that your Silverlight Plugin is not focused at all.  If you click anywhere inside your Silverlight application, then you may notice that the selected rows can be changed with the keyboard arrows.
This means that you need to focus System.Windows.Browser.HtmlPage.Plugin programmatic prior to focusing the GridViewCell as suggested here.

Please let me know in case this does not help.

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Josh
Top achievements
Rank 1
answered on 08 Aug 2011, 05:58 PM
I tried setting the plugin focus before doing the code in all the cases I linked. There is still no change.

The grid population happens due to a search button click, so the plugin already has focus, and I wouldn't think it would have lost it at any time.
0
Accepted
Dimitrina
Telerik team
answered on 10 Aug 2011, 06:46 AM
Hi Josh,

I have created a sample project on how to set a cell focus programmatic. Unfortunately I am not able to reproduce a situation when the cell is not focused.

May you please review the example and guide me on how I may get the behavior that you experience?

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Josh
Top achievements
Rank 1
answered on 10 Aug 2011, 10:50 PM
The example doesn't run for me. I get an error "Cannot create an instance of "RadGridView"".
0
Josh
Top achievements
Rank 1
answered on 15 Aug 2011, 03:57 PM
I got it working now. The problem I was having was I was not using the dispatcher to update the UI. I figured that since it was happening on UI events, that the Dispatcher did not need to be used.

Why does the dispatcher have to be used?
0
Dimitrina
Telerik team
answered on 16 Aug 2011, 10:11 AM
Hello Josh,

 Going through the dispatcher ensures that the elements are already created (i.e. one visual pass has passed). 

We may give you more detailed explanation for the particular case if you can send us a small running sample reproducing the mentioned behavior.

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Tags
GridView
Asked by
Josh
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Josh
Top achievements
Rank 1
Share this question
or