Jump to content
Henry Olive

End Of File

Recommended Posts

Good Day

 

I have a DBGrid and it has some datas which they come from another table

I don't want the user to INSERT a new record, user can just edit available datas

My Code in DBGrid1KeyDown is :

  if (Key=VK_DOWN) then
  if MyTable.RecNo = MyTable.RecordCount then
     Abort;

 

it works, but i'd like to be sure if the logic here is good or there is a better way

 

Thank You

Share this post


Link to post

Hi,

What about using onBeforeInsert event and put in it

procedure TForm1.MyTableBeforeInsert(DataSet: TDataSet);
begin
Dataset.Cancel;
end;
Quote

MyTable.RecNo = MyTable.RecordCount

I am not fan of these two values

Share this post


Link to post

If I understood correctly, it would be better/easier to hide the corresponding button in DBNavigator. 

Share this post


Link to post
16 minutes ago, Stano said:

hide the corresponding button in DBNavigator

That won't catch the keys pressed inside the grid itself. The BeforeInsert event is indeed the best place.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×