si2030
asked on
Integrate a keystroke in datagridviewcombobox that is editable.
Hi Experts
I have a datagridview which has as its first column a datagridviewcombobox. This has been modifed to be editable.
I want to add an autocomplete subroutine that fires off keystrokes in the datagridviewcombobox.
Essentially I want to manage this via a keystoke event..
My issue is: Having pressed a key while in a combobox in the datagridview - how do I capture that keystroke? How do I test to see which combobox it is?
I thought using keyup for the datagridview but how do I know which combobox to work on.
Below is code similar to what I will use for autocomplete - but how to apply that to a combobox in a datagridview??
Simon
I have a datagridview which has as its first column a datagridviewcombobox. This has been modifed to be editable.
I want to add an autocomplete subroutine that fires off keystrokes in the datagridviewcombobox.
Essentially I want to manage this via a keystoke event..
My issue is: Having pressed a key while in a combobox in the datagridview - how do I capture that keystroke? How do I test to see which combobox it is?
I thought using keyup for the datagridview but how do I know which combobox to work on.
Below is code similar to what I will use for autocomplete - but how to apply that to a combobox in a datagridview??
Simon
'This automatically manages autocomplete on the combobox its applied to.
Public Sub autoComplete(ByRef cbx As ComboBox, ByRef e As System.Windows.Forms.KeyEventArgs) Implements clientINTERFACE.IfrmClientDisplay.autoComplete
Try
Select Case e.KeyCode
Case Keys.Left, Keys.Right, Keys.Delete, Keys.End, Keys.Home, Keys.Up, Keys.Down
e.Handled = True
Return
Case Keys.Tab, Keys.ShiftKey
If cbx.Text.Length > 0 Then
cbx.SelectionStart = 0
cbx.SelectionLength = cbx.Text.Length
End If
e.Handled = True
Return
End Select
Select Case e.KeyCode
Case Keys.Back
If cbx.Text.Length = 0 Then
cbx.Text = ""
cbx.SelectionStart = 0
cbx.SelectionLength = cbx.Text.Length
End If
e.Handled = True
Return
End Select
Dim length = cbx.Text.Length
If length > 0 Then
Dim intIdx = cbx.FindString(cbx.Text)
If intIdx >= 0 Then
cbx.SelectedIndex = intIdx
cbx.SelectionStart = length
cbx.SelectionLength = (cbx.Text).ToString.Length - length
End If
End If
ASKER
Hi jpaulino,
The event doesnt seem to fire when I type a series of characters...
http://www.screencast.com/users/si2030/folders/Jing/media/d4e20e84-026e-40c3-bed0-e9bf68df0dd4
Regards
Simon
The event doesnt seem to fire when I type a series of characters...
http://www.screencast.com/users/si2030/folders/Jing/media/d4e20e84-026e-40c3-bed0-e9bf68df0dd4
Regards
Simon
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi jpaulino
Perfect... that worked.
As for JING I only just discovered it a few weeks ago and love it. I am only using the free one also but as they say a picture is worth a 1000 words and in these instances I can explain to you far better using this method rather than some verbose written attempt...
I guess for $14.95 it allows you to do MP4 and higher quality - its not much money :)
Perfect... that worked.
As for JING I only just discovered it a few weeks ago and love it. I am only using the free one also but as they say a picture is worth a 1000 words and in these instances I can explain to you far better using this method rather than some verbose written attempt...
I guess for $14.95 it allows you to do MP4 and higher quality - its not much money :)
Glad I could help and thanks for the information :)
I also found it a few days ago and I'm testing it!
I also found it a few days ago and I'm testing it!
ASKER
working with that last item..thanks
Example:
Open in new window