Delphi XE7, latest TMS component pack, MS SQL via ADO
I have a form with TDBAdvNavigator and a mix of DBAdvEdit fields and DBAdvLookupComboBox items representing the columns.
When I select the + icon to add a new record, the edit boxes and lookup boxes reflect the last record that was in view.
How do I clear the content of these edits so that they do not carry forward into new records? If the user does not manually over-write the values, they populate the new record.
I have tried clearing the values in the onBtnInsert event:
procedure TForm1.MFTNavigatorBtnInsert(Sender: TObject);
ServiceDtEdit.Text := DateToStr(MftDatePicker.DateTime);
MftNoEdit.Text := '';
GHTCVoucherEdit.Text := '';
GHTCAmtEdit.Text := '0';
GHTCDtEdit.Text := '';
ReqCntEdit.Text := '0';
NSCntEdit.Text := '0';
OSReqCntEdit.Text := '0';
OSNSCntEdit.Text := '0';
However, the values of the previous record still persist and are NOT cleared on the new record.
The values in DBAdvEdit and DBAdvLookupComboBox reflect the DB field values of the current record in your dataset. Assuming they display these values correct, not sure why you want/need to remove these? When you would remove this, this will potentially erase the DB field values as well.
I am trying to add a new row using the navigator. I had assumed the values of a NEW record would be available, not the values of the last row displayed.
How do I add a CLEAN and EMPTY row using the navigator and the dbedits?
Do you set DBAdvGrid.RefreshOnInsert = true?
I am not using a grid, only edits and lookups. The users I am doing the project for do not like grids at all. I guess I could put one on and turn off visible property, though that seems to be a ridiculous solution.
Did you test with a regular VCL TDBEdit?
There should not be any difference with respect to values displayed in the control between TDBEdit and TDBAdvEdit, i.e. we implement the standard behavior.
Normally I would use a grid, but because the users demand single instances, that option is out.
I tried the DBAdvFormPanel and DBAdvFormBox but had too many problems with it to spend much time. So I dropped the DBedits on the form and connected the navigator. Works fine except for adding new records.
I have not tried using dbedits before, so have googled to find a clean example. Nada. Everyone uses grids. NO examples of using a navigator with edits. I don't know if it can be done. Since the insert is supposed to start off with an empty record, I was surprised that the data persisted. I guess that because there is no KEY value at the time the user clicks the + button on the navigator that a record can NOT be added. Lacking an actual example, I do not know.
When you press the INS key, the dataset is set in INSERT mode. Until the POST key is pressed, there is no actual data posted to the grid. For a string field, the default value shown in a DBEdit is an empty string when the dataset is in INSERT mode.