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

RadGridView In A User Control

4 Answers 25 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 1
Martin asked on 28 Apr 2016, 11:56 AM

Hi Folks,

I have a user control (WinForms) that has a radGridView placed on it.

I use it on my radForm as follows:

Declare the instance of the control as a member level variable

private UserctlItemMastGridView _gridview;

Then in the constructor of the form I set it up and:

_gridview = new UserctlItemMastGridView();
_gridview.Dock = DockStyle.Fill;
pnlAll.Controls.Add(_gridview);
_gridview.GridClicked += new EventHandler(this._gridview_GridClicked);

Which is fine. I have an event handler which fires when the grid is clicked.

The issue I have is the mouse-wheel scroll is not being fired or captured. Is there a way to raise an event for mouse scroll on the user control and pass it back to the form?

Many thanks,

Martin.

4 Answers, 1 is accepted

Sort by
0
Martin
Top achievements
Rank 1
answered on 28 Apr 2016, 12:16 PM

Hello again,

It seems that an easy solution is to set the focus on the grid control whenever the click event is fired. This works and allows for mouse-wheel scrolling - but I actually want the focus to go to a textbox on the form.

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 29 Apr 2016, 08:16 AM
Hello Martin,

Thank you for writing.

Note that the RadGridView.MouseWheel event will be fired when the grid is currently focused.
You can refer to the following stackOverflow threads demonstrating how to make an event in the UserControl and have it handled in the main form:

http://stackoverflow.com/questions/7880850/how-do-i-make-an-event-in-the-usercontrol-and-have-it-handeled-in-the-main-form
http://stackoverflow.com/questions/2188059/winforms-user-controls-custom-events
http://stackoverflow.com/questions/3486377/how-to-add-an-event-to-a-usercontrol-in-c

I hope this information helps. Should you have further questions I would be glad to help.

 Regards,
Dess
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Martin
Top achievements
Rank 1
answered on 03 May 2016, 12:31 PM

Hi Dess,

The issue here is not firing the event and handling it on the main form - I am already handling the grid Click event this way.

The issue is Handling a scroll / mouse wheel event (which are not available at design time) and handling THIS on the form - whilst also allowing a textbox on the form to receive focus. I am not sure which run-time event to handle - do I have to handle a MouseEventHandler or a generic Event Handler?

I think the easiest way to do this is to apply Grid Focus on the grid click event and set the textbox focus another way.

Thanks,
Martin.

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 05 May 2016, 12:06 PM
Hello Martin,

Thank you for writing back. 

The RadGridView.MouseWheel event is supposed to be fired when the control is currently focused. If you have an event in the UserControl which should fire when the RadGridView.MouseWheel event is fired while another control is focused, you should handle the MouseWheel event of the text box and programmatically force the desired grid event to fire.

I hope this information helps. If you have any additional questions, please let me know.

Regards,
Dess
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
GridView
Asked by
Martin
Top achievements
Rank 1
Answers by
Martin
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or