Article ID: 195983
Article Last Modified on 5/8/2003
Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data
Source=C:\Program Files\Microsoft Visual Studio\VB98\Biblio.mdb
2 - adCmdTable
Authors
ADODC1
Private Declare Function GetWindowText& Lib "user32" _
Alias "GetWindowTextA" _
(ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long)
Private Declare Function GetWindowTextLength& Lib "user32" _
Alias "GetWindowTextLengthA" _
(ByVal hwnd As Long)
Private Function GetCellText(GridControl As DataGrid) As String
'This function takes a DataGrid control and checks its
'edit status. The hWndEditor property is only valid
'when the grid is being edited.
Dim st As String
Dim ch As Long
If GridControl.EditActive Then
ch = GetWindowTextLength(GridControl.hWndEditor) + 1
st = Space(ch)
ch = GetWindowText(GridControl.hWndEditor, st, ch)
GetCellText = Trim(st)
End If
End Function
Private Sub DataGrid1_BeforeColUpdate _
(ByVal ColIndex As Integer, OldValue As Variant, Cancel As Integer)
MsgBox "Cell contents according to CellText property: " & _
DataGrid1.Columns(ColIndex).CellText(DataGrid1.Bookmark)
MsgBox "Cell contents according to Text property: " & _
DataGrid1.Text
MsgBox "Cell contents according to API Calls: " & _
DataGrid1.Tag
End Sub
Private Sub DataGrid1_Change()
' Change is the easiest event to tap into.
' It is fired every time the cell text changes.
' Because you can only save the text when the cell is being edited,
' you have to store the value in another variable if you want
' to use that value in other events.
' Place the contents of the cell into the TAG property as a buffer.
' You could also use a variable to store the information.
DataGrid1.Tag = GetCellText(DataGrid1)
End Sub
Keywords: kbdatabase kbprb kbctrl kbcode KB195983