Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TDBGrid Problem

Status
Not open for further replies.

Ulfeng

Programmer
Dec 9, 2001
12
US
This may be easy but I've poured through the dbGrids.pas and grids.pas files to no avail.
Anyone know how to read the buffered text in the TDBGrid for the current column? I tried to access through the SelectedField.AsString property but that just shows the old field data, not the current text being entered at the current time. I need to do some data validation while the user is typing.

Thanks,
-Jonathan Ulfeng
 
Hello,

You can access a certain column on an drawcolumncell event.
By specifying the column and whether the current cell is selected (if gdSelected in state then) you can do your validation here.

rgds,
Ryan
 
You can also use the SetText and GetText procedure for the DataSet/Query you are using to populate the DBGrid:

procedure TJMSData.qryVenMaintMAILDATESetText(Sender: TField;
const Text: String);
begin
Sender.Value := convertdate(Text);
end;

procedure TJMSData.qryVenMaintMAILDATEGetText(Sender: TField;
var Text: String; DisplayText: Boolean);
begin
if Sender.Value <> '' then
Text := DateFormat(Sender.AsString);
end;

ConvertDate and DateFormat are two functions I wrote in a separate unit that put the date into the proper display format (dateformat) and back to the proper Database format (convertDate). Make sure you have the fields defined for the query.

Hope that helps too.


Leslie
landrews@metrocourt.state.nm.us

SELECT * FROM USERS WHERE CLUE > 0
No Rows Returned
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top