471,120 Members | 1,462 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,120 software developers and data experts.

DatagridView User Control Can not input certain characters.

I add a user control (a simple textbox control) to customize
datagridview column to test how to add user control to datagridview. I
found a weired behavior. I can not input "q", "!", "#".
But I can input other keys (e.g. "Q", "@", "W")

Anybody found this question? It looks like the textbox eat the input
'q' and does not show up in the text.

Public Class DataGridViewEditorButtonEditingControl
Inherits TextBox
Implements IDataGridViewEditingControl
#Region "Vars"

'The grid that owns this editing control
Private dataGridViewControl As DataGridView
'Stores whether the editing control's value has changed or not
Private valueIsChanged As Boolean = False
'Stores the row index in which the editing control resides
Private rowIndexNum As Integer
#End Region

#Region "Implements IDataGridViewEditingControl"
Public Sub ApplyCellStyleToEditingControl(ByVal
dataGridViewCellStyle As System.Windows.Forms.DataGridViewCellStyle)
System.Windows.Forms.IDataGridViewEditingControl.A pplyCellStyleToEditingControl

End Sub

Public Property EditingControlDataGridView() As
System.Windows.Forms.DataGridView Implements
System.Windows.Forms.IDataGridViewEditingControl.E ditingControlDataGridView
Return dataGridViewControl
End Get
Set(ByVal value As System.Windows.Forms.DataGridView)
dataGridViewControl = value
End Set
End Property

Public Property EditingControlFormattedValue() As Object
System.Windows.Forms.IDataGridViewEditingControl.E ditingControlFormattedValue
Return Me.Text
End Get
Set(ByVal value As Object)
If TypeOf value Is [String] Then
Me.Text = value
Me.Text = ""
End If
End Set
End Property

Public Property EditingControlRowIndex() As Integer Implements
System.Windows.Forms.IDataGridViewEditingControl.E ditingControlRowIndex
Return rowIndexNum
End Get
Set(ByVal value As Integer)
rowIndexNum = value
End Set
End Property

Public Property EditingControlValueChanged() As Boolean
System.Windows.Forms.IDataGridViewEditingControl.E ditingControlValueChanged
Return valueIsChanged
End Get
Set(ByVal value As Boolean)
valueIsChanged = value
End Set
End Property

Public Function EditingControlWantsInputKey(ByVal keyData As
System.Windows.Forms.Keys, ByVal dataGridViewWantsInputKey As Boolean)
As Boolean Implements
System.Windows.Forms.IDataGridViewEditingControl.E ditingControlWantsInputKey
Select Case (keyData)
Case Keys.Enter
Return True
Case Else
Return False
End Select
End Function

Public ReadOnly Property EditingPanelCursor() As
System.Windows.Forms.Cursor Implements
System.Windows.Forms.IDataGridViewEditingControl.E ditingPanelCursor
Return MyBase.Cursor
End Get
End Property

Public Function GetEditingControlFormattedValue(ByVal context
As System.Windows.Forms.DataGridViewDataErrorContexts ) As Object
System.Windows.Forms.IDataGridViewEditingControl.G etEditingControlFormattedValue
Return Me.Text
End Function

Public Sub PrepareEditingControlForEdit(ByVal selectAll As
Boolean) Implements
System.Windows.Forms.IDataGridViewEditingControl.P repareEditingControlForEdit
'Do not select all the text, but position the caret at the
start of the text
Me.SelectionStart = 0
Me.SelectionLength = 0
End Sub

Public ReadOnly Property
RepositionEditingControlOnValueChange() As Boolean Implements
System.Windows.Forms.IDataGridViewEditingControl.R epositionEditingControlOnValueChange
Return False
End Get
End Property
#End Region

End Class

Jun 7 '06 #1
0 2327

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by der | last post: by
9 posts views Thread by chuck | last post: by
3 posts views Thread by joey.powell | last post: by
3 posts views Thread by Johnny E. Jensen | last post: by
1 post views Thread by Jeff | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.