Mega Code Archive

 
Categories / Delphi / ADO Database
 

Getting values in a TDBGrid before they are posted

Title: Getting values in a TDBGrid before they are posted Question: How do I know what is being typed into the grid? Answer: You can see what is being typed into a TDBGrid by looking at the TInPlaceEdit control of the TDBGrid. Care should be taken to make sure that the TInPlaceEdit control is created before trying to use it. The following function will show the data in the column of the grid that is being edited: procedure TForm1.DBGrid1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); var B: byte; begin for B := 0 to DBGrid1.ControlCount - 1 do if DBGrid1.Controls[B] is TInPlaceEdit then begin with DBGrid1.Controls[B] as TInPlaceEdit do begin Label1.Caption := 'Text = ' + Text; end; end; end; Please reference TInPlaceEdit in the Delphi 3 help file for more information on it's functionality.