Hi I am still having problems with Tabbing through a DataGrid with a
DataGridComboBox Column.
I need to allow the User to Type the value into the ComboBox so consequently
its ComboBoxStyle is set to DropDown. This causes the Tabbing to work
incorrectly. Even though I am consuming the Windows Message WM_KEYUP, it
still Tabs through the ComboBox Column on to the next Column.
I found if I do not give the keyboard focus ie remark out
ColumnComboBox.Focus the Tabbing works correctly but the ComboBox doesn't.
I tried delaying the sending of the WM_SETFOCUS Message but that didn't work
either.
Can anyone think of a workaround for this or even another way to give the
user similar Functionality. They want to type the value in using the
keyboard but the values are fixed so I have been using the Validating Event
to ensure that they are values from the Combos list. And it helps them to
see the values as in the Combos DropDown.
Any thoughts appreciated.
Doug 10 1949
Try using PreProcessMessage to ignore the KEYUP instead of WndProc.
Public Overrides Function PreProcessMessage(ByRef msg As
System.Windows.Forms.Message) As Boolean
If msg.Msg = WM_KEYUP Then
Return True
End If
Return MyBase.PreProcessMessage(msg)
End Function
===================
Clay Burch
Syncfusion, Inc.
Clay,
Again thanks for your input.
To use "PreProcessMessage" will I have to derive my DataGrid?
Doug
"ClayB" <cl***@syncfusion.comwrote in message
news:11**********************@d57g2000hsg.googlegr oups.com...
Try using PreProcessMessage to ignore the KEYUP instead of WndProc.
Public Overrides Function PreProcessMessage(ByRef msg As
System.Windows.Forms.Message) As Boolean
If msg.Msg = WM_KEYUP Then
Return True
End If
Return MyBase.PreProcessMessage(msg)
End Function
===================
Clay Burch
Syncfusion, Inc.
I get an Error
"'Function PreProcessMessage' can not be declared 'Overrides' because it
does not override a function in the base class"
Am I missing something?
Doug
Clay,
You are a lifesaver.
I owe you a few beers if you get to Sydney.
Thanks,
Doug
Doug,
I had similar problem about half a year ago, and had it solved in a similar
way. I have extended the concept slightly - you may find it useful as well:
Private Sub moveIndex(ByVal count As Integer, ByVal moveDown As Boolean,
ByVal offset As Integer)
Dim origIndex As Integer = Me.SelectedIndex
Dim newIndex As Integer
If moveDown Then
Dim maxIndex As Integer = count - 1
If origIndex < maxIndex Then
newIndex = Math.Min(origIndex + offset, maxIndex)
Else
newIndex = origIndex
End If
ElseIf origIndex 0 Then
newIndex = Math.Max(origIndex - offset, 0)
End If
If newIndex <origIndex Then
Me.SelectedIndex = newIndex
If Not _startEditing Is Nothing Then
_startEditing(Me, System.EventArgs.Empty)
End If
End If
End Sub
Public Overrides Function PreProcessMessage(ByRef msg As
System.Windows.Forms.Message) As Boolean
Dim keyCode As Keys = CType((msg.WParam.ToInt32 And Keys.KeyCode), Keys)
Dim baseProcess As Boolean = True
If msg.Msg = _WM_KEYDOWN Then
Select Case keyCode
Case Keys.Up, Keys.Down, Keys.PageUp, Keys.PageDown
baseProcess = False
Dim count As Integer = Me.Items.Count
If count 0 Then
Select Case keyCode
Case Keys.Up
moveIndex(count, False, 1)
Case Keys.Down
moveIndex(count, True, 1)
Case Else
Dim pageCount As Integer = Me.MaxDropDownItems
If keyCode = Keys.PageUp Then
moveIndex(count, False, pageCount)
ElseIf keyCode = Keys.PageDown Then
moveIndex(count, True, pageCount)
End If
End Select
End If
End Select
End If
Dim result As Boolean = True
If baseProcess Then
result = MyBase.PreProcessMessage(msg)
End If
Return result
End Function
Placing the above code inside the combo allows it to react to the navigation
button events
HTH
"Doug Bell" wrote:
Clay,
You are a lifesaver.
I owe you a few beers if you get to Sydney.
Thanks,
Doug
Hi Thanks Sergey,
I took my project in yesterday for "Show and Tell" and the combo Navigation
was one of their next requests.
(I should have put a functional specification together)
I was going to try to try and work out a solution this morning so perfect
timing
..
Can you explain your "_startEditing" ?
The Code I have is pretty much based on Clay's example.
What is your _startEditing ?
Thanks
Doug
"Sergey Poberezovskiy" <Se*****************@discussions.microsoft.comwrot e
in message news:A0**********************************@microsof t.com...
Doug,
I had similar problem about half a year ago, and had it solved in a
similar
way. I have extended the concept slightly - you may find it useful as
well:
>
Private Sub moveIndex(ByVal count As Integer, ByVal moveDown As Boolean,
ByVal offset As Integer)
Dim origIndex As Integer = Me.SelectedIndex
Dim newIndex As Integer
If moveDown Then
Dim maxIndex As Integer = count - 1
If origIndex < maxIndex Then
newIndex = Math.Min(origIndex + offset, maxIndex)
Else
newIndex = origIndex
End If
ElseIf origIndex 0 Then
newIndex = Math.Max(origIndex - offset, 0)
End If
If newIndex <origIndex Then
Me.SelectedIndex = newIndex
If Not _startEditing Is Nothing Then
_startEditing(Me, System.EventArgs.Empty)
End If
End If
End Sub
Public Overrides Function PreProcessMessage(ByRef msg As
System.Windows.Forms.Message) As Boolean
Dim keyCode As Keys = CType((msg.WParam.ToInt32 And Keys.KeyCode), Keys)
Dim baseProcess As Boolean = True
If msg.Msg = _WM_KEYDOWN Then
Select Case keyCode
Case Keys.Up, Keys.Down, Keys.PageUp, Keys.PageDown
baseProcess = False
Dim count As Integer = Me.Items.Count
If count 0 Then
Select Case keyCode
Case Keys.Up
moveIndex(count, False, 1)
Case Keys.Down
moveIndex(count, True, 1)
Case Else
Dim pageCount As Integer = Me.MaxDropDownItems
If keyCode = Keys.PageUp Then
moveIndex(count, False, pageCount)
ElseIf keyCode = Keys.PageDown Then
moveIndex(count, True, pageCount)
End If
End Select
End If
End Select
End If
Dim result As Boolean = True
If baseProcess Then
result = MyBase.PreProcessMessage(msg)
End If
Return result
End Function
Placing the above code inside the combo allows it to react to the
navigation
button events
HTH
"Doug Bell" wrote:
Clay,
You are a lifesaver.
I owe you a few beers if you get to Sydney.
Thanks,
Doug
Sergey, to clarify,
I have the navigation keys working with your extra code but I just wondered
what your
"startEditing" was doing?
Doug
"Sergey Poberezovskiy" <Se*****************@discussions.microsoft.comwrot e
in message news:A0**********************************@microsof t.com...
Doug,
I had similar problem about half a year ago, and had it solved in a
similar
way. I have extended the concept slightly - you may find it useful as
well:
>
Private Sub moveIndex(ByVal count As Integer, ByVal moveDown As Boolean,
ByVal offset As Integer)
Dim origIndex As Integer = Me.SelectedIndex
Dim newIndex As Integer
If moveDown Then
Dim maxIndex As Integer = count - 1
If origIndex < maxIndex Then
newIndex = Math.Min(origIndex + offset, maxIndex)
Else
newIndex = origIndex
End If
ElseIf origIndex 0 Then
newIndex = Math.Max(origIndex - offset, 0)
End If
If newIndex <origIndex Then
Me.SelectedIndex = newIndex
If Not _startEditing Is Nothing Then
_startEditing(Me, System.EventArgs.Empty)
End If
End If
End Sub
Public Overrides Function PreProcessMessage(ByRef msg As
System.Windows.Forms.Message) As Boolean
Dim keyCode As Keys = CType((msg.WParam.ToInt32 And Keys.KeyCode), Keys)
Dim baseProcess As Boolean = True
If msg.Msg = _WM_KEYDOWN Then
Select Case keyCode
Case Keys.Up, Keys.Down, Keys.PageUp, Keys.PageDown
baseProcess = False
Dim count As Integer = Me.Items.Count
If count 0 Then
Select Case keyCode
Case Keys.Up
moveIndex(count, False, 1)
Case Keys.Down
moveIndex(count, True, 1)
Case Else
Dim pageCount As Integer = Me.MaxDropDownItems
If keyCode = Keys.PageUp Then
moveIndex(count, False, pageCount)
ElseIf keyCode = Keys.PageDown Then
moveIndex(count, True, pageCount)
End If
End Select
End If
End Select
End If
Dim result As Boolean = True
If baseProcess Then
result = MyBase.PreProcessMessage(msg)
End If
Return result
End Function
Placing the above code inside the combo allows it to react to the
navigation
button events
HTH
"Doug Bell" wrote:
Clay,
You are a lifesaver.
I owe you a few beers if you get to Sydney.
Thanks,
Doug
Doug,
_startEditing is a private variable that I initialise in the
comboconstructor - it refers to AddressOf selectionChangeCommit procedure in
DataGridComboboxColumn class.
Here is the constructor for the DataGridComboboxColumn:
Public Sub New()
' Create our own customized Combobox, which is used in the DataGrid
_cbo = New gridComboBox(AddressOf selectionChangeCommit)
_cbo.DropDownStyle = ComboBoxStyle.DropDownList
' GridComboBox subscribes to the Leave Event. It occurs when the
' input focus leaves the ComboBox.
AddHandler _cbo.Leave, AddressOf leaveComboBox
' GridComboBox subscribes to the SelectionChangeCommitted Event.
' It occurs when the selected item has changed and that change
' is committed (save the changed data to the DataGrid TextBox).
AddHandler _cbo.SelectionChangeCommitted, AddressOf selectionChangeCommit
End Sub
Now the actual procedure:
' The ColumnStartedEditing method allows the DataGrid
' to show a pencil in the row header indicating the row
' is being edited. (base is the parent DataGridTextBoxColumn)
Private Sub selectionChangeCommit(ByVal sender As System.Object, ByVal e As
System.EventArgs)
_editing = True
MyBase.ColumnStartedEditing(CType(sender, Control))
End Sub
And leave procedure:
' Handle Combobox Behaviour when Focus leaves the Combobox.
Private Sub leaveComboBox(ByVal sender As System.Object, ByVal e As
System.EventArgs)
If _editing Then
' Set the Combobox ValueMember to the current RowColumn
' when the Focus leaves the Combobox.
SetColumnValueAtRow(_currencyManager, _rowNum, _cbo.Text)
_editing = False
' Redraws the column
Invalidate()
End If
' Hide the current Combobox when Focus on Combobox is lost
_cbo.Hide()
End Sub
I think that should cover most of it. My task was to create combobox display
different lists on different grid rows, so some of the code may not be
relevant, but it should not hurt either.
If the code above does not work or I have missed something again, let me know
Serge
"Doug Bell" wrote:
Sergey, to clarify,
I have the navigation keys working with your extra code but I just wondered
what your
"startEditing" was doing?
Doug
"Sergey Poberezovskiy" <Se*****************@discussions.microsoft.comwrot e
in message news:A0**********************************@microsof t.com...
Doug,
I had similar problem about half a year ago, and had it solved in a
similar
way. I have extended the concept slightly - you may find it useful as
well:
Private Sub moveIndex(ByVal count As Integer, ByVal moveDown As Boolean,
ByVal offset As Integer)
Dim origIndex As Integer = Me.SelectedIndex
Dim newIndex As Integer
If moveDown Then
Dim maxIndex As Integer = count - 1
If origIndex < maxIndex Then
newIndex = Math.Min(origIndex + offset, maxIndex)
Else
newIndex = origIndex
End If
ElseIf origIndex 0 Then
newIndex = Math.Max(origIndex - offset, 0)
End If
If newIndex <origIndex Then
Me.SelectedIndex = newIndex
If Not _startEditing Is Nothing Then
_startEditing(Me, System.EventArgs.Empty)
End If
End If
End Sub
Public Overrides Function PreProcessMessage(ByRef msg As
System.Windows.Forms.Message) As Boolean
Dim keyCode As Keys = CType((msg.WParam.ToInt32 And Keys.KeyCode), Keys)
Dim baseProcess As Boolean = True
If msg.Msg = _WM_KEYDOWN Then
Select Case keyCode
Case Keys.Up, Keys.Down, Keys.PageUp, Keys.PageDown
baseProcess = False
Dim count As Integer = Me.Items.Count
If count 0 Then
Select Case keyCode
Case Keys.Up
moveIndex(count, False, 1)
Case Keys.Down
moveIndex(count, True, 1)
Case Else
Dim pageCount As Integer = Me.MaxDropDownItems
If keyCode = Keys.PageUp Then
moveIndex(count, False, pageCount)
ElseIf keyCode = Keys.PageDown Then
moveIndex(count, True, pageCount)
End If
End Select
End If
End Select
End If
Dim result As Boolean = True
If baseProcess Then
result = MyBase.PreProcessMessage(msg)
End If
Return result
End Function
Placing the above code inside the combo allows it to react to the
navigation
button events
HTH
"Doug Bell" wrote:
Clay,
>
You are a lifesaver.
>
I owe you a few beers if you get to Sydney.
>
Thanks,
>
Doug
>
>
>
Thanks
Doug
"Sergey Poberezovskiy" <Se*****************@discussions.microsoft.comwrot e
in message news:92**********************************@microsof t.com...
Doug,
_startEditing is a private variable that I initialise in the
comboconstructor - it refers to AddressOf selectionChangeCommit procedure
in
DataGridComboboxColumn class.
Here is the constructor for the DataGridComboboxColumn:
Public Sub New()
' Create our own customized Combobox, which is used in the DataGrid
_cbo = New gridComboBox(AddressOf selectionChangeCommit)
_cbo.DropDownStyle = ComboBoxStyle.DropDownList
' GridComboBox subscribes to the Leave Event. It occurs when the
' input focus leaves the ComboBox.
AddHandler _cbo.Leave, AddressOf leaveComboBox
' GridComboBox subscribes to the SelectionChangeCommitted Event.
' It occurs when the selected item has changed and that change
' is committed (save the changed data to the DataGrid TextBox).
AddHandler _cbo.SelectionChangeCommitted, AddressOf selectionChangeCommit
End Sub
Now the actual procedure:
' The ColumnStartedEditing method allows the DataGrid
' to show a pencil in the row header indicating the row
' is being edited. (base is the parent DataGridTextBoxColumn)
Private Sub selectionChangeCommit(ByVal sender As System.Object, ByVal e
As
System.EventArgs)
_editing = True
MyBase.ColumnStartedEditing(CType(sender, Control))
End Sub
And leave procedure:
' Handle Combobox Behaviour when Focus leaves the Combobox.
Private Sub leaveComboBox(ByVal sender As System.Object, ByVal e As
System.EventArgs)
If _editing Then
' Set the Combobox ValueMember to the current RowColumn
' when the Focus leaves the Combobox.
SetColumnValueAtRow(_currencyManager, _rowNum, _cbo.Text)
_editing = False
' Redraws the column
Invalidate()
End If
' Hide the current Combobox when Focus on Combobox is lost
_cbo.Hide()
End Sub
I think that should cover most of it. My task was to create combobox
display
different lists on different grid rows, so some of the code may not be
relevant, but it should not hurt either.
If the code above does not work or I have missed something again, let me
know
>
Serge
"Doug Bell" wrote:
Sergey, to clarify,
I have the navigation keys working with your extra code but I just
wondered
what your
"startEditing" was doing?
Doug
"Sergey Poberezovskiy" <Se*****************@discussions.microsoft.com>
wrote
in message news:A0**********************************@microsof t.com...
Doug,
>
I had similar problem about half a year ago, and had it solved in a
similar
way. I have extended the concept slightly - you may find it useful as
well:
>
Private Sub moveIndex(ByVal count As Integer, ByVal moveDown As
Boolean,
ByVal offset As Integer)
Dim origIndex As Integer = Me.SelectedIndex
Dim newIndex As Integer
If moveDown Then
Dim maxIndex As Integer = count - 1
If origIndex < maxIndex Then
newIndex = Math.Min(origIndex + offset, maxIndex)
Else
newIndex = origIndex
End If
ElseIf origIndex 0 Then
newIndex = Math.Max(origIndex - offset, 0)
End If
If newIndex <origIndex Then
Me.SelectedIndex = newIndex
If Not _startEditing Is Nothing Then
_startEditing(Me, System.EventArgs.Empty)
End If
End If
End Sub
>
Public Overrides Function PreProcessMessage(ByRef msg As
System.Windows.Forms.Message) As Boolean
Dim keyCode As Keys = CType((msg.WParam.ToInt32 And Keys.KeyCode),
Keys)
Dim baseProcess As Boolean = True
If msg.Msg = _WM_KEYDOWN Then
Select Case keyCode
Case Keys.Up, Keys.Down, Keys.PageUp, Keys.PageDown
baseProcess = False
Dim count As Integer = Me.Items.Count
If count 0 Then
Select Case keyCode
Case Keys.Up
moveIndex(count, False, 1)
Case Keys.Down
moveIndex(count, True, 1)
Case Else
Dim pageCount As Integer = Me.MaxDropDownItems
If keyCode = Keys.PageUp Then
moveIndex(count, False, pageCount)
ElseIf keyCode = Keys.PageDown Then
moveIndex(count, True, pageCount)
End If
End Select
End If
End Select
End If
Dim result As Boolean = True
If baseProcess Then
result = MyBase.PreProcessMessage(msg)
End If
Return result
End Function
>
Placing the above code inside the combo allows it to react to the
navigation
button events
>
HTH
>
"Doug Bell" wrote:
>
Clay,
You are a lifesaver.
I owe you a few beers if you get to Sydney.
Thanks,
Doug This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Gamze |
last post by:
Hi,
How can i get values from datagrid to combobox and should select the same
name as in datagrid row on the combobox control
In my vb.net windows application ,i have combobox which is...
|
by: Bill C. |
last post by:
Hello,
I know this has been discussed a lot already because I've been searching
around for information the last few weeks.
I'm trying to implement a DataGridComboBoxColumn class. I've found...
|
by: Bill C. |
last post by:
Hi,
I'm trying to implement a ComboBox drop-down column for a DataGrid.
When a cell is selected in the ComboBox column I overlay a ComboBox
over the cell and call:
this.comboBox.Show();...
|
by: Kevin |
last post by:
Hi Al
I want to add two combobox columns in my datagrid. the one combobox column must be bound to the same datasource that the datagrid is, and the other combobox I just want to populate with a...
|
by: PeterZ |
last post by:
G'day,
After doing much searching and pinching bits of ideas from here there and
everywhere I came up with a fairly 'clean' solution of including a comboBox
into a dataGrid column.
You can...
|
by: pei_world |
last post by:
I want to implement a key hit with enter to dropdown a combobox that is in
the datagrid. in this case I need to override its original behaviours. I
found some codes from the web. Does anyone know...
|
by: TT (Tom Tempelaere) |
last post by:
Hay there,
I'm writing my own DataGridComboBoxColumn because .NET 1.1 does not have one
(I hope .NET 2.0 supplies one). I based it on this article:...
|
by: Doug |
last post by:
Hi
I have the following code (not mine) that populates a datagrid with some
file names. But I want to replace the datagrid with a combo box.
private void OnCurrentDataCellChanged(object sender,...
|
by: jimb |
last post by:
I can get the dropdownlist into the datagrid, and I can populate it, but I
can't read it.
Anybody have a working example of a dropdownlist in an editable grid?
Thanks.
--
.....
|
by: Jan Nielsen |
last post by:
Hi all
I'm a former Access developer who would like to implement a many-to-many
relation in about the same way you do in Access: With a subform and a combo
box.
Is it possible to use a...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: erikbower65 |
last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps:
1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal.
2. Connect to...
|
by: kcodez |
last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
|
by: Taofi |
last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same
This are my field names
ID, Budgeted, Actual, Status and Differences
...
|
by: Rina0 |
last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
|
by: DJRhino |
last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer)
If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _
310030356 Or 310030359 Or 310030362 Or...
|
by: lllomh |
last post by:
How does React native implement an English player?
|
by: Mushico |
last post by:
How to calculate date of retirement from date of birth
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
| |