Topic: ComboBox
I have on a combobox 3 choices. (Choice 1, Choice 2, Choice 3)
every time I call the form I want to have the first Choice written on the Combobox and not to be blank.
The combobox is not from a record field.
My Visual Database → Script → ComboBox
I have on a combobox 3 choices. (Choice 1, Choice 2, Choice 3)
every time I call the form I want to have the first Choice written on the Combobox and not to be blank.
The combobox is not from a record field.
Hello
I think there is a default index in the object inspector. Set it to 1 instead of 0 and that should do the trick
I know but it doesn't work when it is with a script.
The combobox is empty and I <<fill>> it using a script
ComboBox1.Items.Add ('Choice 1');
ComboBox1.Items.Add ('Choice 2');
ComboBox1.Items.Add ('Choice 3');
So the values are not from a record, the combobox is not linked with any table.
Everytime I open the form the combobox is blank, until I click on it.
I need the ComboBox every time I open the form to have the first Choice, and I think that this will hapend only with a script, but I do not know the way to write it.
Sorry, I misunderstood your question.
If your default choice is number 1 in list, did you try ::
procedure Form1_OnShow (Sender: string; Action: string);
begin
Form1.ComboBox1.Items.Add ('Choice 1');
Form1.ComboBox1.Items.Add ('Choice 2');
Form1.ComboBox1.Items.Add ('Choice 3');
Form1.ComboBox1.ItemIndex := 0;
end;
If you want to turn back to empty Combobox on show, put ItemIndex := -1
Cheers
Mathias
Also you should to add Clear function
procedure Form1_OnShow (Sender: string; Action: string);
begin
Form1.ComboBox1.Items.Clear;
Form1.ComboBox1.Items.Add ('Choice 1');
Form1.ComboBox1.Items.Add ('Choice 2');
Form1.ComboBox1.Items.Add ('Choice 3');
Form1.ComboBox1.ItemIndex := 0;
end;
Haaaaa Dmitry... clever
This is to come back to default choice on next OnShow event right ?
Right.
My Mistake was that I dind't write the script Form1.ComboBox1.ItemIndex := 0;
Instate that I choose from the Object for the combobox the DefaultIndex=1
Thanks for your help....once again
My Visual Database → Script → ComboBox
Powered by PunBB, supported by Informer Technologies, Inc.
Theme Hydrogen by Kushi