If your idea is to get the user to edit the selected content on DBLookupComboBox, this may not be possible as the purpose of this control is to list the data of a table as specified in the property ListSource.
If that’s what you want to do, maybe the DBComboBox can best serve this case.
What you can do to get around this is through the event onClick one-button.
const
MSG1 = 'Digite uma nova espécie:';
MSG2 = 'Tem certeza que deseja gravar a espécie %s no banco?';
var
Entrada: string;
begin
Entrada := InputBox(Caption, MSG1, '');
if Length(Entrada) = 0 then Exit;
if MessageDlg(Format(MSG2, [Entrada]), mtConfirmation, [mbYes, mbNo], 0) = mrNo then Exit;
Tabela1.Append;
Tabela1.FieldByName('Campo1').AsString := Entrada;
...
It is necessary to link the property ListSource of DBLookupComboBox at the DataSource of the desired table.
Let’s say you have an animal, and when choosing the a species in dblookcombobox there is no relative, so you want the user can register a new species, choose it and then register the animal?
– Artur_Indio
@Artur_indio, I want him to type in his own combo and already register.
– Giovani
Programmatically there are many ways to do this, using the Dblookupcombobox or Dbcombobox components will not work because you cannot edit them. You can use a Combobox and then load the items from the dataset to it and then let the user edit and put a new one, when you click the save button you make a way to also save the species table, the way you save and generate the id will be the id that goes to animal.
– Artur_Indio
@Artur_indio, would I have to set some property to allow the user to edit? Formulate this in an answer that I believe will solve my problem :D
– Giovani
@Artur_indio, eh como dito pelo Qmechanic73?
– Giovani
I think that as stated by Qmechanic73 does not, because you have to save the species ID before, to save the animal using the species ID, the animal table has a foreign key to the right species?
– Artur_Indio
@Artur_indio, I agree with you, you have to do it this way. Thank you very much
– Giovani
I particularly do this way, I use Dblookupcombobox to bring the species names, in case you don’t have the species for that animal I put a button next to Dblookupcombobox that opens a window to register the new species, when the user type the name of the species and give the ok, I give a refresh in the dataset which the Dblookupcombobox is on and put it to the last record, in case what the user has just registered.
– Artur_Indio
Cool @Artur_indio, a great idea
– Giovani