Thanks Brian for the clues to doing this right. By doing it right in this
context I mean something other than changing row currentcy to force the value
to stay glued down.
Here's what I ended up doing FWIW:
Public Class dgcs
Inherits DataGridTextBoxColumn
Dim mNewValue As Object
Dim isEditing As Boolean = False
Property newValue() As Object
Get
Return mNewValue
End Get
Set(ByVal Value As Object)
mNewValue = Value
If Me.DataGridTableStyle.DataGrid.Parent Is Nothing Then
Exit Property
Me.isEditing = True
Dim dgt As DataGrid = Me.DataGridTableStyle.DataGrid
Dim r As Integer = dgt.CurrentCell.RowNumber
Dim cm As CurrencyManager = CType(dgt.Parent,
Form).BindingContext(dgt.DataSource)
Me.Commit(cm, r)
End Set
End Property
Protected Overrides Function Commit(ByVal dataSource As
System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer) As Boolean
If Me.isEditing Then
Me.isEditing = False
SetColumnValueAtRow(dataSource, rowNum, Me.mNewValue)
Me.HideEditBox() ' THIS IS CRUCIAL
Me.Invalidate()
End If
Commit = True
End Function
End Class
......
Private Sub putDate(ByVal d As Date)
Dim curDgcs As dgcs =
Me.DataGrid1.TableStyles(0).GridColumnStyles(Me.DataGrid1.CurrentCell.ColumnNumber)
curDgcs.newValue = d
End Sub
Private Sub miYesterday_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles miYesterday.Click
Me.putDate(Today.AddDays(-1))
End Sub
Private Sub miToday_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles miToday.Click
Me.putDate(Today)
End Sub
--
Things I didn't show - the conversion of the relevant column styles from the
standard to my class. I did a no no and dis this in the windows generated
code.
The user right clicks in a cell, picks yesterday or today. The click event
causes the right newvalue to be set and the commit makes sure that it is
displayed.
By calling commit from the newValue setting property I get the kind of
automatic behavior we've been looking for here.
WHAT IS EVEN MORE MAGICAL is that for whatever reason if i have the column
as the sort, things reorder correctly without further intervention on my
part!!!!!
I'm going to modify this a bit further so that the sql gets fired off to
update the underlying tables. (This is NOT trivial in my particular case for
a variety of reasons
))
Now, if I could only figure out how to get the (*&^(*&^ EM_SETTABSTOPS to
work. (If you have a clue search for my posting of the other day on the
subject in these forums.)
Regards,
Al Christoph
Senior Consultant and Proprietor
Three Bears Software, LLC
just right software @ just right prices @3bears.biz