Topic: Using Combobox items as buttons.

I'm trying to use combobox items as buttons except the first combo item. I like to use first combo item as combo caption. Combobox is on main form (form1)


Combo items:
Print
Print Selected
Print All
First empty item unchecked (false) on combo properties.


Buttons part seems to be OK but getting first combo item displayed as combo caption on form1 show is not?

procedure Form1_OnShow (Sender: string; Action: string);
begin
  Form1.ComboBox1.Clear;
  Form1.ComboBox1.Items.Add('Print');
  Form1.ComboBox1.Items.Add('Print All');
  Form1.ComboBox1.Items.Add('Print Selected');
  Form1.ComboBox1.Text := 'Print';
  Form1.edCombo1Value.Text := 'Print';
end;

procedure Form1_ComboBox1_OnChange (Sender: string);
begin
  Form1.edCombo1Value.Text := Form1.ComboBox1.Text;
  if Form1.ComboBox1.Text = 'Print All' then Form1.Button2.Click;
  if Form1.ComboBox1.Text = 'Print Selected' then Form1.Button3.Click;
end;

Please see the attached sample project below if needed.

Post's attachments

Attachment icon Using Combo as Button.zip 5.04 kb, 363 downloads since 2017-08-11 

Adam
God... please help me become the person my dog thinks I am.

Re: Using Combobox items as buttons.

Unfortunately I can't understand the problem.

Dmitry.

Re: Using Combobox items as buttons.

DriveSoft wrote:

Unfortunately I can't understand the problem.


Combo items:
Print
Print Selected
Print All


First combo item (Print) is not associated to any button action. I wanted to display first combo item Print on combobox as a caption on Form1 show always. If I was to use buttons only then I'd have to use 2 buttons, one for print all and other for print selected. With combobox approach I'd use one button space.


However, currently I'm using disabled textbox with default value (Print) over combobox as a workaround.

Adam
God... please help me become the person my dog thinks I am.

Re: Using Combobox items as buttons.

Check it out

procedure Form1_OnShow (Sender: string; Action: string);
begin
  Form1.ComboBox1.Clear;
  Form1.ComboBox1.Items.Add('Print');
  Form1.ComboBox1.Items.Add('Print All');
  Form1.ComboBox1.Items.Add('Print Selected');
  Form1.ComboBox1.ItemIndex := 0;
  Form1.edCombo1Value.Text := 'Print';
end;

procedure Form1_ComboBox1_OnChange (Sender: string);
begin
  Form1.edCombo1Value.Text := Form1.ComboBox1.Text;
  if Form1.ComboBox1.Text = 'Print All' then Form1.Button2.Click;
  if Form1.ComboBox1.Text = 'Print Selected' then Form1.Button3.Click;
  Form1.ComboBox1.ItemIndex := 0;
end;
Dmitry.

Re: Using Combobox items as buttons.

DriveSoft wrote:

Check it out ...


Now it works fine.
Thank you very much Dmitry................
Truly appreciated...................

Adam
God... please help me become the person my dog thinks I am.