Topic: Combobox

Hello,

how can i make selections in combobox and copy them to a textbox?

for example:

if i have a combobox with 3 choices:

text1
text2
text3

if i click on text1 it will add "text1" in a textbox, and the same for the other options.

Re: Combobox

Hello

This perhaps

Form1.Edit1.Text  :=  Form1.ComboBox1.Text;

JB

Re: Combobox

But if i want to save two fields of the same combobox? I think i have to add a button and create  a onclick event right?

For example if i have the three fields that i said in my first post, i want to choose text1 in the combobox and click on the button to add text1 in a textbox, but after i choose text2 on the combobox and click on the button it will add text2 on the same textbox and it will appear for example in the textbox:

text1,text2

Is this possible?

Re: Combobox

Please, send me your project with description.


Thanks.

Dmitry.

Re: Combobox

i dont have a project yet, i'm just making examples to learn a little more.

basically i want to click on the choices that i have on combobox and copy them to a texbox.

6 (edited by Montenegr0 2015-03-28 19:16:58)

Re: Combobox

i did this:

procedure Form1_Button4_OnClick (Sender: string; var Cancel: boolean);
begin
Form1.Edit3.Text  :=  Form1.ComboBox1.Text;
end;

but it works fine only if i just want to choose one option of the combobox, because if i choose another and click on the button it will erase my first choise that is on the textbox and will write second, but what i want is to send as many choices of the combobox that i want and separate them with "," on the textbox.



or send instead of the textbox send to a memo and make each choice per line.

i dont know how to do it sad

Re: Combobox

try this

procedure Form1_Button4_OnClick (Sender: string; var Cancel: boolean);
begin
   Form1.Edit3.Text  :=  Form1.Edit3.Text  + Form1.ComboBox1.Text +', ';
end;
Dmitry.

Re: Combobox

i was already thinking in while cycles and everything else, and you make it so simple.



thanks

Re: Combobox

Hello

I am a complete newbie at this and was trying to follow this example to copy the entries from a multi select combi box into  a data field using the following as per below

procedure Form1_Button4_OnClick (Sender: string; var Cancel: boolean);
begin
   Form1.Edit3.Text  :=  Form1.Edit3.Text  + Form1.ComboBox1.Text +', ';
end;

However i get an Error message near 'procedure':syntax error

Is it right that the above text is added to the scripts tab?

Re: Combobox

Hi,
Not entirely sure what you're after.
If it's putting the values of a multi-select combobox into an edit field, you just need to overwrite what's already in the edit field as it will always show all the selected values anyway (see Form1 in the attachment).
If it's adding values into an edit field one by one from a (not multi select) combobox, have a look at Form2 in the attachment. 
In both cases (Form1 and Form2), the script fires when the comboboxes are closed up rather than using a discrete button.
It's helpful if you can attach the project that your question relates to so that people can understand the exact problem (zip up the folder but without the .exe (which gets recreated every time you run your program)).
Derek.

Post's attachments

Attachment icon randykoala.zip 337.78 kb, 113 downloads since 2022-08-27 

Re: Combobox

Thanks Derek - worked like a charm .

Will tidy up and post my project if i have another query