RadGridView In A User Control

5 posts, 0 answers
  1. Martin
    Martin avatar
    35 posts
    Member since:
    Jun 2014

    Posted 28 Apr Link to this post

    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.

  2. Martin
    Martin avatar
    35 posts
    Member since:
    Jun 2014

    Posted 28 Apr in reply to Martin Link to this post

    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.

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 29 Apr Link to this post

    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.
  5. Martin
    Martin avatar
    35 posts
    Member since:
    Jun 2014

    Posted 03 May in reply to Dess Link to this post

    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.

  6. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 05 May Link to this post

    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.
Back to Top
UI for WinForms is Visual Studio 2017 Ready