We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

custom cell - keypress Issue

Hi, I created a custom cell by derived CellModel and CellRenderer classes and placed in the grid. Issue 1: On keypress on that cell of grid is not activating the contol but the same happens on mouse click. Issue 2: On Arrow keypress in that custom control moves the focus to next cell rather than traversing in that custom control. Please suggest me solution for the above issues. Thanks in advance. Regards, Vamsi Krishna.

4 Replies

AD Administrator Syncfusion Team November 30, 2003 02:30 PM UTC

1) In your derived cell control, override OnKeyDown and activate the cell control by calling CurrentCell.BeginEdit there (while you handle the initial keystroke). If you have the source code, you can look at the GridTextBoxCellRenderer.OnKeyDown to see how that cell control handles activating the control when the first key is pressed. 2) You need to override ProcessKeyEventArgs in the cell renderer class. In your override, if you want the embedded control to handle the key message, then you need to call the ProcessKeyEventArgs method on the embedded control. To do this since the ProcessKeyEventArgs method is protected, you need to derive the control class you are using and expose a public method that calls its ProcessKeyEventArgs method. If you look at the GridInCells sample, it uses the ProcessKeyEventArgs override to allow the embedded grid to handle the arrow keys instead of letting the parent grid handle them.

VK vamsi krishna December 3, 2003 12:07 AM UTC

Hi Clay Burch, Thank you very for the solution. I am able to resolve both the issues. I have one more issue. My custom control is a UserContorl which works like a date picker. It has maskeditbox,button,popupcontrol container and a month calender. On click of button will open a month calender. Now the issue is on mouse click in the region where my button is there in the cell i want the popup to come but on the first click in that cell the focus goes to control and after another click my popup comes. So it making me to double click to choose the date. Is it possible to trap the mouse click position say if it is in the last 20 pixels position then call the control button click event rather than focusing the control. Please suggest me solution to resolve this issue. Thanks in advance. Regards, Vamsi.

AD Administrator Syncfusion Team December 3, 2003 07:21 AM UTC

Try overriding your renderer''s OnClick method. In the override, check where the mouse position is, and if it is close to your button, then show your popup. To do this, you probably will have to expose the PopupContainer and Button so the renderer can access them in some manner (maybe make them public or add public methods to handle it).
Protected Overrides Sub OnClick(ByVal rowIndex As Integer, ByVal colIndex As Integer, ByVal e As System.Windows.Forms.MouseEventArgs)
        MyBase.OnClick(rowIndex, colIndex, e)
        Dim userCtl As CALDatePicker = Me.Control
        Dim pt As Point = userCtl.PointToClient(Control.MousePosition)
        Dim rect As Rectangle = userCtl.btnImage.Bounds
        rect = New Rectangle(rect.Left - 20, rect.Y, rect.Width + 20, rect.Height)
        If rect.Contains(pt) Then
        End If
    End Sub

VK vamsi krishna December 4, 2003 09:17 AM UTC

Thank you very much. Now my issue is resolved.

Live Chat Icon For mobile
Up arrow icon