Note that there are some explanatory texts on larger screens.

plurals
  1. POUserControl in Custom DataGridViewCell Ignoring First Keystroke
    primarykey
    data
    text
    <p>I have a custom <code>DataGridViewCell</code> with a user-control as its editing control. The cell was built in the style of this article: <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcell.initializeeditingcontrol.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcell.initializeeditingcontrol.aspx</a></p> <p>For the most part, this works great. The problem is that the regular behavior of a <code>DataGridViewCell</code> is to pass the keystroke used to enter EditMode to the control, but that's not happening for this cell.</p> <p>Example:</p> <p>I select the custom date cell, and type in "12/24/2008", the "1" begins EditMode, and "2/24/2008" appears in the cell.</p> <p>How do I get the first keystroke to the editing control?</p> <pre><code>Public Class DataGridViewDateCell Public Overrides Function KeyEntersEditMode(ByVal e As System.Windows.Forms.KeyEventArgs) As Boolean 'Any key-sequences with modifiers will not enter edit mode' If e.Control Or e.Shift Or e.Alt Then Return False 'Accept numbers, '/', and '-'' If (e.KeyCode &gt;= Keys.NumPad0 And e.KeyCode &lt;= Keys.NumPad9) OrElse _ (Char.IsDigit(ChrW(e.KeyCode))) OrElse _ e.KeyCode = Keys.Subtract OrElse _ e.KeyCode = Keys.Divide OrElse _ e.KeyCode = Keys.OemMinus OrElse _ e.KeyCode = Keys.OemQuestion Then Return True End If 'Any other keys should be ignored' Return False End Function Public Overrides ReadOnly Property EditType() As System.Type Get Return GetType(DataGridViewDateEditingControl) End Get End Property End Class </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload