473,320 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Cor: DataGridComboColumnStyle

Cor,

I found a previous message from you on the newsgroups with code for a
DataGridComboColumnStyle.. This one seems to work a lot better than the
one that I wrote, however I'm having a couple of problems. One, if I tab
into the column, it won't stay there. It immediately goes into the next
column. The second one, is if you are not in the column, the value of
the combo is not displaying in the column when the combo disappears.

I am using relatively the same code, however I made one change. I made
the Combobox public, so that I could modify some of it's properties from
outside of the ColumnStyle. I did this because I wanted to set the
selectedvalue bindings, and I couldn't find a New() method that did that
so I cheated. :)

Any help with these would be greatly appreciated.
Thanks,
Aaron
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #1
12 1025
Forget the first problem. Solved that by changing the inheritance from a
columnstyle to the textboxcolumn. But I still can't keep it from
focusing out of the column when I tab into it.

Aaron Smith wrote:
Cor,

I found a previous message from you on the newsgroups with code for a
DataGridComboColumnStyle.. This one seems to work a lot better than the
one that I wrote, however I'm having a couple of problems. One, if I tab
into the column, it won't stay there. It immediately goes into the next
column. The second one, is if you are not in the column, the value of
the combo is not displaying in the column when the combo disappears.

I am using relatively the same code, however I made one change. I made
the Combobox public, so that I could modify some of it's properties from
outside of the ColumnStyle. I did this because I wanted to set the
selectedvalue bindings, and I couldn't find a New() method that did that
so I cheated. :)

Any help with these would be greatly appreciated.
Thanks,
Aaron

--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #2
And if it's any clue to anyone why this is happening, if I have a break
point in the edit sub, it won't leave the combo box, it will stay there.
Take the break point out, and it will leave every time.....

Aaron Smith wrote:
Forget the first problem. Solved that by changing the inheritance from a
columnstyle to the textboxcolumn. But I still can't keep it from
focusing out of the column when I tab into it.

Aaron Smith wrote:
Cor,

I found a previous message from you on the newsgroups with code for a
DataGridComboColumnStyle.. This one seems to work a lot better than
the one that I wrote, however I'm having a couple of problems. One, if
I tab into the column, it won't stay there. It immediately goes into
the next column. The second one, is if you are not in the column, the
value of the combo is not displaying in the column when the combo
disappears.

I am using relatively the same code, however I made one change. I made
the Combobox public, so that I could modify some of it's properties
from outside of the ColumnStyle. I did this because I wanted to set
the selectedvalue bindings, and I couldn't find a New() method that
did that so I cheated. :)

Any help with these would be greatly appreciated.
Thanks,
Aaron


--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #3
Ok. Just forget this whole thing.

Private WM_KEYUP As Integer = &H101

Protected Overrides Sub WndProc(ByRef m As
System.Windows.Forms.Message)
If m.Msg = WM_KEYUP Then
'ignore keyup to avoid problem with tabbing & dropdownlist;
Return
End If
MyBase.WndProc(m)
End Sub 'WndProc

In the derived combo fixes it. Thanks for letting me talk it through on
the newsgroup. lol

Aaron Smith wrote:
And if it's any clue to anyone why this is happening, if I have a break
point in the edit sub, it won't leave the combo box, it will stay there.
Take the break point out, and it will leave every time.....

Aaron Smith wrote:
Forget the first problem. Solved that by changing the inheritance from
a columnstyle to the textboxcolumn. But I still can't keep it from
focusing out of the column when I tab into it.

Aaron Smith wrote:
Cor,

I found a previous message from you on the newsgroups with code for a
DataGridComboColumnStyle.. This one seems to work a lot better than
the one that I wrote, however I'm having a couple of problems. One,
if I tab into the column, it won't stay there. It immediately goes
into the next column. The second one, is if you are not in the
column, the value of the combo is not displaying in the column when
the combo disappears.

I am using relatively the same code, however I made one change. I
made the Combobox public, so that I could modify some of it's
properties from outside of the ColumnStyle. I did this because I
wanted to set the selectedvalue bindings, and I couldn't find a New()
method that did that so I cheated. :)

Any help with these would be greatly appreciated.
Thanks,
Aaron



--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #4
I have the same problem and posted about it twice and got no answer. I was
just going to intercept the "tab" key and move it over manually, but I can
not even figure out how to catch the "tab" key for the column because the
keypress doesn't fire when you hit tab. If anyone can capture the "tab" key
when presssed on a datagrid, please enlighten me.

I banged my head against it for days and then just told my boss it was a
feature.
Chris
"Aaron Smith" <th**********@smithcentral.net> wrote in message
news:tB*******************@newssvr33.news.prodigy. com...
Forget the first problem. Solved that by changing the inheritance from a
columnstyle to the textboxcolumn. But I still can't keep it from focusing
out of the column when I tab into it.

Aaron Smith wrote:
Cor,

I found a previous message from you on the newsgroups with code for a
DataGridComboColumnStyle.. This one seems to work a lot better than the
one that I wrote, however I'm having a couple of problems. One, if I tab
into the column, it won't stay there. It immediately goes into the next
column. The second one, is if you are not in the column, the value of the
combo is not displaying in the column when the combo disappears.

I am using relatively the same code, however I made one change. I made
the Combobox public, so that I could modify some of it's properties from
outside of the ColumnStyle. I did this because I wanted to set the
selectedvalue bindings, and I couldn't find a New() method that did that
so I cheated. :)

Any help with these would be greatly appreciated.
Thanks,
Aaron

--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.

Nov 21 '05 #5
Do you have a link to the orginal post Cor did? I have an overriden
combobox and a datagridcolumnstyle, but you solution to the tab problem did
not help mine. The keyup event never fired when I use tab. I'm missing
something simple here I'm sure.

Chris
"Aaron Smith" <th**********@smithcentral.net> wrote in message
news:PQ*******************@newssvr33.news.prodigy. com...
Ok. Just forget this whole thing.

Private WM_KEYUP As Integer = &H101

Protected Overrides Sub WndProc(ByRef m As
System.Windows.Forms.Message)
If m.Msg = WM_KEYUP Then
'ignore keyup to avoid problem with tabbing & dropdownlist;
Return
End If
MyBase.WndProc(m)
End Sub 'WndProc

In the derived combo fixes it. Thanks for letting me talk it through on
the newsgroup. lol

Aaron Smith wrote:
And if it's any clue to anyone why this is happening, if I have a break
point in the edit sub, it won't leave the combo box, it will stay there.
Take the break point out, and it will leave every time.....

Aaron Smith wrote:
Forget the first problem. Solved that by changing the inheritance from a
columnstyle to the textboxcolumn. But I still can't keep it from
focusing out of the column when I tab into it.

Aaron Smith wrote:

Cor,

I found a previous message from you on the newsgroups with code for a
DataGridComboColumnStyle.. This one seems to work a lot better than the
one that I wrote, however I'm having a couple of problems. One, if I
tab into the column, it won't stay there. It immediately goes into the
next column. The second one, is if you are not in the column, the value
of the combo is not displaying in the column when the combo disappears.

I am using relatively the same code, however I made one change. I made
the Combobox public, so that I could modify some of it's properties
from outside of the ColumnStyle. I did this because I wanted to set the
selectedvalue bindings, and I couldn't find a New() method that did
that so I cheated. :)

Any help with these would be greatly appreciated.
Thanks,
Aaron


--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.

Nov 21 '05 #6
I got the original from here: http://tinyurl.com/6dvvd

There are two different column styles on that page. So here is what I
finally came up with:

This does not have the tab problem when it's a drop down list.

Public Class DataGridComboBox
Inherits ComboBox
Private WM_KEYUP As Integer = &H101

Protected Overrides Sub WndProc(ByRef m As
System.Windows.Forms.Message)
If m.Msg = WM_KEYUP Then
'ignore keyup to avoid problem with tabbing & dropdownlist;
Return
End If
MyBase.WndProc(m)
End Sub 'WndProc

Public Sub New()
MyBase.New()
End Sub
Private _modified As Boolean = False
Public isInEditOrNavigateMode As Boolean = True

Public Property Modified() As Boolean
Get
Return _modified
End Get
Set(ByVal Value As Boolean)
_modified = Value
End Set
End Property
End Class

<DataSysDescription("This column style adds a ComboBox to the Column")> _
Public Class DataGridComboBoxColumn
Inherits DataGridTextBoxColumn
'
' UI constants
'
Private xMargin As Integer = 2
Private yMargin As Integer = 1
Private WithEvents Combo As DataGridComboBox
Private WithEvents tb As TextBox = Me.TextBox
Private _DisplayMember As String
Private _ValueMember As String
Private _rowNum As Integer
Private WithEvents _source As CurrencyManager
'
' Used to track editing state
'
Private OldVal As String = String.Empty
Private InEdit As Boolean = False
'
' Create a new column - DisplayMember, ValueMember
' Passed by ordinal
'
Public Sub New()
Combo = New DataGridComboBox
Combo.Visible = False
End Sub

Public Sub New(ByRef DataSource As DataTable, ByVal DisplayMember
As Integer, ByVal ValueMember As Integer)
Debug.WriteLine("New(1)")
Combo = New DataGridComboBox
_DisplayMember =
DataSource.Columns.Item(index:=DisplayMember).ToSt ring
_ValueMember = DataSource.Columns.Item(index:=ValueMember).ToStri ng
With Combo
.Visible = False
.DataSource = DataSource
.DisplayMember = _DisplayMember
.ValueMember = _ValueMember
End With
End Sub
'
' Create a new column - DisplayMember, ValueMember
' passed by string
'
Public Sub New(ByRef DataSource As DataTable, ByVal DisplayMember
As String, ByVal ValueMember As String)
Debug.WriteLine("New(2)")
Combo = New DataGridComboBox
With Combo
.Visible = False
.DataSource = DataSource
.DisplayMember = DisplayMember
.ValueMember = ValueMember
End With
End Sub
Public Sub New(ByRef DataSource As DataView, ByVal DisplayMember As
Integer, ByVal ValueMember As Integer)
Debug.WriteLine("New(3)")
Combo = New DataGridComboBox
_DisplayMember =
DataSource.Table.Columns.Item(index:=DisplayMember ).ToString()
_ValueMember =
DataSource.Table.Columns.Item(index:=ValueMember). ToString()
With Combo
.Visible = False
.DataSource = DataSource
.DisplayMember = _DisplayMember
.ValueMember = _ValueMember
End With
End Sub
'
' Create a new column - DisplayMember, ValueMember
' passed by string
'
Public Sub New(ByRef DataSource As DataView, ByVal DisplayMember As
String, ByVal ValueMember As String)
Debug.WriteLine("New(4)")
Combo = New DataGridComboBox
With Combo
.Visible = False
.DataSource = DataSource
.DisplayMember = DisplayMember
.ValueMember = ValueMember
End With
End Sub

'------------------------------------------------------
' Methods overridden from DataGridColumnStyle

'------------------------------------------------------
'
' Abort Changes
'
Protected Overloads Overrides Sub Abort(ByVal RowNum As Integer)
Debug.WriteLine("Abort()")
RollBack()
HideComboBox()
EndEdit()
End Sub
'
' Commit Changes
'
Protected Overloads Overrides Function Commit(ByVal DataSource As
CurrencyManager, ByVal RowNum As Integer) As Boolean
Debug.WriteLine("Commit()")
HideComboBox()
_rowNum = RowNum
_source = DataSource
If Not InEdit Then
Return True
End If

Try
Dim Value As Object = Combo.SelectedValue
If NullText.Equals(Value) Then
Value = Convert.DBNull
End If
tb.Text = Combo.Text
SetColumnValueAtRow(DataSource, RowNum, Value)
Catch e As Exception
RollBack()
Return False
End Try
EndEdit()
Return True
End Function
'
' Remove focus
'
Protected Overloads Overrides Sub ConcedeFocus()
Debug.WriteLine("ConcedeFocus()")
Combo.Visible = False
End Sub
'
' Edit Grid
'
Protected Overloads Overrides Sub Edit(ByVal Source As
CurrencyManager, ByVal Rownum As Integer, ByVal Bounds As Rectangle,
ByVal [ReadOnly] As Boolean, ByVal InstantText As String, ByVal
CellIsVisible As Boolean)
Debug.WriteLine("Edit()")
Combo.Text = String.Empty
Dim OriginalBounds As Rectangle = Bounds
Dim txt As String
OldVal = Combo.Text
If CellIsVisible Then
Bounds.Offset(xMargin, yMargin)
Bounds.Width -= xMargin * 2
Bounds.Height -= yMargin
Combo.Bounds = Bounds
Combo.Visible = True
Else
Combo.Bounds = OriginalBounds
Combo.Visible = False
End If

txt = tb.Text
If Not txt = InstantText Then
Combo.Modified = True
End If
If Not txt = NullText Then
Combo.SelectedValue = GetText(GetColumnValueAtRow(Source,
Rownum))
End If

If Not InstantText Is Nothing Then
Combo.SelectedValue = InstantText
End If

Combo.RightToLeft = Me.DataGridTableStyle.DataGrid.RightToLeft
Combo.Focus()

If InstantText Is Nothing Then
Combo.SelectAll()
Else
Dim [End] As Integer = Combo.Text.Length
Combo.Select([End], 0)
End If

If Combo.Visible Then
DataGridTableStyle.DataGrid.Invalidate(OriginalBou nds)
End If

InEdit = True
End Sub
Protected Overloads Overrides Function GetMinimumHeight() As Integer
'
' Set the minimum height to the height of the combobox
'
Debug.WriteLine("GetMinimumHeight()")
Return Combo.PreferredHeight + yMargin
End Function
Protected Overloads Overrides Function GetPreferredHeight(ByVal g
As Graphics, ByVal Value As Object) As Integer
Debug.WriteLine("GetPreferredHeight()")
Dim NewLineIndex As Integer = 0
Dim NewLines As Integer = 0
Dim ValueString As String = Me.GetText(Value)
Do
While NewLineIndex <> -1
NewLineIndex = ValueString.IndexOf("r\n", NewLineIndex + 1)
NewLines += 1
End While
Loop

Return FontHeight * NewLines + yMargin
End Function

Protected Overloads Overrides Function GetPreferredSize(ByVal g As
Graphics, ByVal Value As Object) As Size
Dim Extents As Size =
Size.Ceiling(g.MeasureString(GetText(Value),
Me.DataGridTableStyle.DataGrid.Font))
Debug.WriteLine("GetPreferredSize()")
Extents.Width += xMargin * 2 + DataGridTableGridLineWidth
Extents.Height += yMargin
Return Extents
End Function

Protected Overloads Overrides Sub Paint(ByVal g As Graphics, ByVal
Bounds As Rectangle, ByVal Source As CurrencyManager, ByVal RowNum As
Integer)
Debug.WriteLine("Paint(1)")
Paint(g, Bounds, Source, RowNum, False)
End Sub

Protected Overloads Overrides Sub Paint(ByVal g As Graphics, ByVal
Bounds As Rectangle, ByVal Source As CurrencyManager, ByVal RowNum As
Integer, ByVal AlignToRight As Boolean)
Debug.WriteLine("Paint(2)" &
GetText(GetColumnValueAtRow(Source, RowNum)))
Dim Text As String = GetText(GetColumnTextAtRow(Source, RowNum))
PaintText(g, Bounds, Text, AlignToRight)
End Sub

Protected Overloads Sub Paint(ByVal g As Graphics, ByVal Bounds As
Rectangle, ByVal Source As CurrencyManager, ByVal RowNum As Integer,
ByVal BackBrush As Brush, ByVal ForeBrush As Brush, ByVal AlignToRight
As Boolean)
Debug.WriteLine("Paint(3)")
Dim Text As String = GetText(GetColumnTextAtRow(Source, RowNum))
PaintText(g, Bounds, Text, BackBrush, ForeBrush, AlignToRight)
End Sub

Protected Overloads Overrides Sub SetDataGridInColumn(ByVal Value
As DataGrid)
Debug.WriteLine("SetDataGridInColumn()")
MyBase.SetDataGridInColumn(Value)
If Not (Combo.Parent Is Value) Then
If Not (Combo.Parent Is Nothing) Then
Combo.Parent.Controls.Remove(Combo)
End If
End If

If Not (Value Is Nothing) Then Value.Controls.Add(Combo)
If Not (tb.Parent Is Value) Then
If Not (tb.Parent Is Nothing) Then
tb.Parent.Controls.Remove(tb)
End If
End If

If Not (Value Is Nothing) Then Value.Controls.Add(tb)
End Sub

Protected Overloads Overrides Sub UpdateUI(ByVal Source As
CurrencyManager, ByVal RowNum As Integer, ByVal InstantText As String)
Debug.WriteLine("UpdateUI()")
Combo.Text = tb.Text
If Not (InstantText Is Nothing) Then
Combo.Text = InstantText
End If
End Sub
'----------------------------------------------------------------------
' Helper Methods

'----------------------------------------------------------------------
Public Property ComboBox() As DataGridComboBox
Get
Return Combo
End Get
Set(ByVal Value As DataGridComboBox)
Combo = Value
End Set
End Property

Private ReadOnly Property DataGridTableGridLineWidth() As Integer
Get
If Me.DataGridTableStyle.GridLineStyle =
DataGridLineStyle.Solid Then
Return 1
Else
Return 0
End If
End Get
End Property

Private Shadows Sub EndEdit()
Debug.WriteLine("EndEdit()")
InEdit = False
Combo.Modified = False
Invalidate()
End Sub
Private Function GetText(ByVal Value As Object) As String
If Not Value Is Nothing Then
Debug.WriteLine("GetText(" & Value.ToString & ")")
Else
Debug.WriteLine("GetText(Value is Nothing)")
End If
If Value Is System.DBNull.Value Then Return NullText
If Not Value Is Nothing Then
Debug.WriteLine(Value.ToString)
Return Value.ToString
Else
Debug.WriteLine("Value is Nothing")
Return String.Empty
End If
End Function
Private Sub HideComboBox()
Debug.WriteLine("HideComboBox()")
If Combo.Focused Then
Me.DataGridTableStyle.DataGrid.Focus()
End If
Combo.Visible = False
End Sub

Private Sub RollBack()
Debug.WriteLine("RollBack()")
Combo.Text = OldVal
tb.Text = OldVal
Combo.Modified = False
End Sub

Private Shadows Sub PaintText(ByVal g As Graphics, ByVal Bounds As
Rectangle, ByVal Text As String, ByVal AlignToRight As Boolean)
Debug.WriteLine("PaintText(1)")
Dim BackBrush As Brush = New
SolidBrush(Me.DataGridTableStyle.BackColor)
Dim ForeBrush As Brush = New
SolidBrush(Me.DataGridTableStyle.ForeColor)
PaintText(g, Bounds, Text, BackBrush, ForeBrush, AlignToRight)
End Sub

Private Shadows Sub PaintText(ByVal g As Graphics, ByVal TextBounds
As Rectangle, ByVal Text As String, ByVal BackBrush As Brush, ByVal
ForeBrush As Brush, ByVal AlignToRight As Boolean)
Debug.WriteLine("PaintText(2)" & Text)
Dim Rect As Rectangle = TextBounds
Dim RectF As RectangleF = RectF.op_Implicit(Rect) ' Convert to
RectangleF()
Dim Format As StringFormat = New StringFormat
If AlignToRight Then
Format.FormatFlags = StringFormatFlags.DirectionRightToLeft
End If
Select Case Me.Alignment
Case Is = HorizontalAlignment.Left
Format.Alignment = StringAlignment.Near
Case Is = HorizontalAlignment.Right
Format.Alignment = StringAlignment.Far
Case Is = HorizontalAlignment.Center
Format.Alignment = StringAlignment.Center
End Select
Format.FormatFlags = Format.FormatFlags Or StringFormatFlags.NoWrap
g.FillRectangle(Brush:=BackBrush, Rect:=Rect)
Rect.Offset(0, yMargin)
Rect.Height -= yMargin
g.DrawString(Text, Me.DataGridTableStyle.DataGrid.Font,
ForeBrush, RectF, Format)
Format.Dispose()
End Sub

Private Function GetColumnTextAtRow(ByVal Source As
CurrencyManager, ByVal RowNum As Integer) As Object
Dim value As Object = Me.GetColumnValueAtRow(Source, RowNum)
Dim dSource As Object
dSource = Combo.DataSource
If value Is System.DBNull.Value Then
Return NullText
End If
If Not dSource Is Nothing Then
If TypeOf dSource Is DataTable Then
Dim dr As DataRow
dSource = CType(dSource, DataTable)
If Not dSource.Columns.Contains(Combo.DisplayMember) _
OrElse Not dSource.Columns.Contains(Combo.ValueMember) Then
Return NullText
End If
For Each dr In dSource.Rows
If value = dr(Combo.ValueMember) Then
Return dr(Combo.DisplayMember)
End If
Next
Return NullText
ElseIf TypeOf dSource Is DataView Then
Dim drv As DataRowView
dSource = CType(dSource, DataView)
If Not
dSource.Table.Columns.Contains(Combo.DisplayMember ) _
OrElse Not
dSource.Table.Columns.Contains(Combo.ValueMember) Then
Return NullText
End If
For Each drv In dSource
If value = drv(Combo.ValueMember) Then
Return drv(Combo.DisplayMember)
End If
Next
Return NullText
End If
End If
End Function
Private Sub Combo_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles Combo.SelectedIndexChanged
tb.Text = CType(sender, ComboBox).Text
End Sub
End Class

Chris, Master of All Things Insignificant wrote:
Do you have a link to the orginal post Cor did? I have an overriden
combobox and a datagridcolumnstyle, but you solution to the tab problem did
not help mine. The keyup event never fired when I use tab. I'm missing
something simple here I'm sure.

Chris
"Aaron Smith" <th**********@smithcentral.net> wrote in message
news:PQ*******************@newssvr33.news.prodigy. com...
Ok. Just forget this whole thing.

Private WM_KEYUP As Integer = &H101

Protected Overrides Sub WndProc(ByRef m As
System.Windows.Forms.Message)
If m.Msg = WM_KEYUP Then
'ignore keyup to avoid problem with tabbing & dropdownlist;
Return
End If
MyBase.WndProc(m)
End Sub 'WndProc

In the derived combo fixes it. Thanks for letting me talk it through on
the newsgroup. lol

Aaron Smith wrote:
And if it's any clue to anyone why this is happening, if I have a break
point in the edit sub, it won't leave the combo box, it will stay there.
Take the break point out, and it will leave every time.....

Aaron Smith wrote:
Forget the first problem. Solved that by changing the inheritance from a
columnstyle to the textboxcolumn. But I still can't keep it from
focusing out of the column when I tab into it.

Aaron Smith wrote:
>Cor,
>
>I found a previous message from you on the newsgroups with code for a
>DataGridComboColumnStyle.. This one seems to work a lot better than the
>one that I wrote, however I'm having a couple of problems. One, if I
>tab into the column, it won't stay there. It immediately goes into the
>next column. The second one, is if you are not in the column, the value
>of the combo is not displaying in the column when the combo disappears.
>
>I am using relatively the same code, however I made one change. I made
>the Combobox public, so that I could modify some of it's properties
>from outside of the ColumnStyle. I did this because I wanted to set the
>selectedvalue bindings, and I couldn't find a New() method that did
>that so I cheated. :)
>
>Any help with these would be greatly appreciated.
>Thanks,
>Aaron



--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.


--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #7
Aaron,

I had not a situation with two comboboxes side by side with this, so I had
to make it, now I have it.

(For the next time)

Hower nice you solved it.

(No problem really smilling)

:-)

Cor
Nov 21 '05 #8
Cor, two things.

1. can you explain what is going on in the background to make this happen?
2. The solution that Aaron came up with is:
Private WM_KEYUP As Integer = &H101

Protected Overrides Sub WndProc(ByRef m As
System.Windows.Forms.Message)
If m.Msg = WM_KEYUP Then
'ignore keyup to avoid problem with tabbing & dropdownlist;
Return
End If
MyBase.WndProc(m)
End Sub 'WndProc

Isn't this the same event that you would catch if you overrode the keyup
event? Or am I mixing two concepts I have no business mixing.

Chris
"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Aaron,

I had not a situation with two comboboxes side by side with this, so I had
to make it, now I have it.

(For the next time)

Hower nice you solved it.

(No problem really smilling)

:-)

Cor

Nov 21 '05 #9
Chris,

In my opinion are we talking about different things.

You are not the only one who is looking to get the control over the tabbing
in a datagrid.

I did not see as well a solution for that.

There are some links telling about that change, however than it is as far as
I have seen about the position change or rowindex change or about a value
change in a column (item)

Even when you catch the tab key, you have to know where it is and the
columns are resizable, looks for me a hell of a job.

Sorry, I cannot help you (yet) with this.

Cor
Nov 21 '05 #10
Did that work for you?

Chris, Master of All Things Insignificant wrote:
Cor, two things.

1. can you explain what is going on in the background to make this happen?
2. The solution that Aaron came up with is:
Private WM_KEYUP As Integer = &H101

Protected Overrides Sub WndProc(ByRef m As
System.Windows.Forms.Message)
If m.Msg = WM_KEYUP Then
'ignore keyup to avoid problem with tabbing & dropdownlist;
Return
End If
MyBase.WndProc(m)
End Sub 'WndProc

Isn't this the same event that you would catch if you overrode the keyup
event? Or am I mixing two concepts I have no business mixing.

Chris

Nov 21 '05 #11
I tied adding your code to my inherited combobox but it did not help. My
implimentation is a little different than yours as I overrode the
datagridcolumnstyle class, not the datagridtextboxcolumn class to put my
combo box into the grid. I'm going to have to take some time to look in
depth at Cor's solution to see if I can swap it out for mine. It's going to
have to wait a few days as I don't have the time do devote to it now.

Thanks for all you insights though. At least I know there is a solution
now.
Chris
"Aaron Smith" <th**********@smithcentral.net> wrote in message
news:kV*******************@newssvr33.news.prodigy. com...
Did that work for you?

Chris, Master of All Things Insignificant wrote:
Cor, two things.

1. can you explain what is going on in the background to make this
happen?
2. The solution that Aaron came up with is:
Private WM_KEYUP As Integer = &H101

Protected Overrides Sub WndProc(ByRef m As
System.Windows.Forms.Message)
If m.Msg = WM_KEYUP Then
'ignore keyup to avoid problem with tabbing & dropdownlist;
Return
End If
MyBase.WndProc(m)
End Sub 'WndProc

Isn't this the same event that you would catch if you overrode the keyup
event? Or am I mixing two concepts I have no business mixing.

Chris

Nov 21 '05 #12
Chris,

Thinkink it over I thought I had once made a sample that used the
datacolumns events.
However I am not very happy with it, maybe I look today to it, trying to get
it better, however maybe you can use it.

\\\
Private WithEvents dtbCol1 As DataGridTextBox
Private ToolTip1 As New ToolTip
')
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Datagrid1.ReadOnly = True
Dim ts As New DataGridTableStyle
ts.MappingName = ds.Tables(0).TableName
Dim column As New DataGridTextBoxColumn
ts.GridColumnStyles.Add(column)
DataGrid1.TableStyles.Add(ts)
column = DirectCast(ts.GridColumnStyles(0), DataGridTextBoxColumn)
dtbCol1 = DirectCast(column.TextBox, DataGridTextBox)
column.MappingName = ds.Tables(0).Columns(0).ColumnName
column.HeaderText = "Cor"
column.Width = 30
dv = New DataView(ds.Tables(0))
dv.AllowNew = False
DataGrid1.DataSource = dv
End Sub
Private Sub dtbCol1_ToolTip(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles dtbCol1.MouseEnter
ToolTip1.SetToolTip(DirectCast(sender, DataGridTextBox), _
"Row: " & DataGrid1.CurrentRowIndex + 1)
End Sub
///

I hope this helps?

Cor


Nov 21 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Varun | last post by:
Hi Cor U earlier help me with coding for removing items from a combobox based on what is contained in my array What i wanted to ask was advise on a similar situation i have encountered. Im not...
1
by: Jiten | last post by:
Hi Cor I spoke with u previously about this problem i had and u gave me some code that helped me. That code worked fine but i have now encountered another issuee that im hoping u may know how to...
8
by: scorpion53061 | last post by:
I know this may sound strange but I wanted to throw this at you guys as you seem to be the "framework" of this NG. I think you guys are great at giving help. Thank you for the help you have...
6
by: ToddT | last post by:
why don't you guys just exchange email addresses?
8
by: MadCrazyNewbie | last post by:
Hey CJ/Cor/William, Hope you could advise me a little again? Now i`ve got in my Button Click Event on my first form(frmFaxs): Dim LoadFaxMeterReadings As frmFaxMeterReadings()...
1
by: Miguel Dias Moura | last post by:
Hi Cor and everybody else, i created a page with 5 panels and 5 buttons which control them acording to Cor's help. After this i used 5 image buttons instead of standard buttons. When i run...
12
by: Bernie Yaeger | last post by:
I asked two fairly simple questions, or so I thought, but have received no ideas at all. 1. What is the control that MS uses in Outlook Express that contains attachments? It appears to be a...
15
by: Cesar Ronchese | last post by:
Hi, I built the sample code showing the problem with dates when viewed at different machines, different Time Zones and transported via Remoting. The zip can be downloaded here: ...
1
by: fiaolle | last post by:
Hi I Have found examples of the class DataGridComboColumnStyle, but I don't really know how to use it. I have tried to add this columnstyle and ordinary columnstyles and insert data to the...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.