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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prevent adding new record to DBGrid

Status
Not open for further replies.

Dhagaxtuur

Technical User
Apr 15, 2003
47
CA
I have editable dbgrid and when ever I use the down click on the key board. It tries to add new record after the last column. How can I prevent that so it stops when last column is reached. I am using Borland c++ builder 6
 
I think you need to set the grid to read only. You can do this via the component's method or programatically
Code:
BDGrid->ReadOnly=true;
;

There may be conditions that you want to look for that can change this or that you may want to change.

James P. Cottingham

When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity.
[tab][tab]Albert Einstein explaining his Theory of Relativity to a group of journalists.
 
I want the information to be edited. I am using statistics for large number of people. I make the first column readonly but all the other columns need to be editable. What I want is to prevent the pointer to down to a blank record after the last record on the grid. THnks
 
I want the information to be edited. I am using to record statistics for large number of people. I make the first column readonly but all the columns need to be editable. What I want is to prevent the pointer to down to a blank record after the last record on the grid. THnks
 
void __fastcall TForm1::DBGrid1KeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if ((Key == VK_DOWN) && (Table1->RecNo == Table1->RecordCount))
Key = NULL;
}

tomcruz.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top