Topic: Editable combobox

Hi everyone,
               I want to know that a combobox can be editable? If yes, how it can be?

Re: Editable combobox

unforgettable,


By editable do you just want to be able to add items to the combobox or edit them as well?

To add an item directly to the combobox:


 { Function to check if  combobox has had a new item added to it}

 frmEditPart.cmbEditCategory.dbItemID := add2ComboBox(frmEditPart.cmbEditCategory.text, frmEditPart.cmbEditCategory.dbItemID);



{function to allow selected comboboxes to have new data added to them directly}


function add2ComboBox (Sender: String;  indx: Integer): Integer;
begin
   if (indx = -1)  AND (Sender <> '') then
       begin
         SQLExecute('INSERT INTO table (field) VALUES ("'+Sender+'")');
         UpdateDatabase('TABLE');
         Result := Last_Insert_id;
         showmessage('TABLE updated with '+Sender )
      end
      else begin
       Result := indx;
   end;


end; 
On a clear disk you can seek forever

Re: Editable combobox

Thanks CDB. I want to add data if it is not in combobox. Where do I type these codes on which event? On click event? Can you attached any project as example?

4 (edited by CDB 2020-11-25 11:38:43)

Re: Editable combobox

Here you go Unforgettable.


This program is one I use to test out things.   All you need to look at is the drop down box. I have used the code in the 'On Close Up' event.

You could if you wished put the calling code in the 'OnClick' event or even have a button with the calling code in.


To use, just type a word into the drop down box without opening the drop down. It will then appear in the table grid and also in the drop down list after you have clicked outside the combobox.

Post's attachments

Attachment icon unforgettable.zip 339.99 kb, 238 downloads since 2020-11-25 

On a clear disk you can seek forever

5 (edited by unforgettable 2020-11-25 17:50:42)

Re: Editable combobox

Thank you CDB attaching project which guide me what I want to know. Thanks again.