Gridview gets and losses focus every x seconds

1 Answer 38 Views
GridView
Daniel
Top achievements
Rank 2
Iron
Iron
Daniel asked on 22 Aug 2024, 02:53 PM

Hi Telerik support team,

I got into problems with a gridview. It seems that the grid losses focus and directly gets focus back. This happens every 1 or 2 seconds. I’ve created a small application with a simple grid with datasource and handlers for the Got- and LostFocus. Add a breakpoint on it and it will hit constantly.

My problem gets bigger because the datasource also gets kind of refreshed. In the sample application I’ve a class Person. Put there a breakpoint on the Name getter and every second or 2 it will hit.

Start the application, don’t click around, just wait. The breakpoints will hit.

What’s happening with the focus on the grid?? Why is it getting ‘stolen’? Can I prevent this behavior?

In the sample application look into the FocusIssueForm.

Regards,

Daniel

1 Answer, 1 is accepted

Sort by
0
Accepted
Nadya | Tech Support Engineer
Telerik team
answered on 27 Aug 2024, 08:17 AM

Hello, Daniel,

The provided project is greatly appreciated.

While testing the grid I remark the following things. GotFocus/LostFocus does not trigger every 1 or 2 seconds as you described. GotFocus triggers at the beginning when you run the project, before the form is shown it hits the breakpoint. Here you can check the output window in the Visual Studio:

When I continue to perform further actions and click with the mouse somewhere else, the focus from the grid gets lost and LostFocus triggers, which is normal. Once the form is loaded and RadGridView is shown, these events are triggered as expected when you focus/unfocus grid. The datasource is also set once, it is not refresh when you just focus grid on every 2 seconds. I added the MS DataGridView control just to compare it to RadGridView. Both behave in a similar way. The only difference is that RadGridView gets focused initially when form is showing and this is not an issue. I printed messages in the respective events, so that you can check them. Just open the output window and run the project.

When the project runs RadGridView gets focused. It remains focused until you move the focus from grid. After that LostFocus trigger only when you intentionally change the focus over control. I attached the project to this thread so you can give it a try. 

Can you please provide further details what exactly you are trying to achieve? Do you need to suppress these events or what is the desired behavior that you need to achieve with RadGridView? Providing more details will be helpuf in understanding your case and think of suitable solution for your case.

I am looking forward to your reply.

Regards,
Nadya | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Daniel
Top achievements
Rank 2
Iron
Iron
commented on 27 Aug 2024, 10:53 AM

Hi Nadya,

Thanks for your reaction and sample. When using writelines in the eventhandlers it indeed does not hit every 2 seconds. I guess it's Visual Studio which plays with the focus. 

Thanks for your help!

Daniel

Tags
GridView
Asked by
Daniel
Top achievements
Rank 2
Iron
Iron
Answers by
Nadya | Tech Support Engineer
Telerik team
Share this question
or