Board index » delphi » Tcombobox

Tcombobox

I have a Tcombobox on a form.
At form activate event I fill the listbox.
Then I use the code
ComboBox1.Text := ComboBox1.Items[0];
to specify a value.

The problem is I have edit1 linked to the
value in combobox1 and this doesnt fire the
procedure TForm1.ComboBox1Change(Sender: TObject);

I thought about messing with dropdown method I saw
awhile back when browsing, but it says its
only for tdbcombobox.

If there is an easy way, I'd be interested to hear it.
Otherwise dont spend a lot of time responding to this.

There usually is another way to do something.

Thanks
jim

 

Re:Tcombobox


You will have to fire the OnChange handler yourself with:

type
  TMyComboBox = class(TComboBox);

procedure TForm1.FormCreate(Sender: TObject);
begin
  ComboBox1.Text := ComboBox1.Items[0];
  TMyComboBox(ComboBox1).Change;
end;

"Eoyore" <m...@slic.com> schreef in bericht
news:3949D3C5.D1FE6FA2@slic.com...

Quote
> I have a Tcombobox on a form.
> At form activate event I fill the listbox.
> Then I use the code
> ComboBox1.Text := ComboBox1.Items[0];
> to specify a value.

> The problem is I have edit1 linked to the
> value in combobox1 and this doesnt fire the
> procedure TForm1.ComboBox1Change(Sender: TObject);

> I thought about messing with dropdown method I saw
> awhile back when browsing, but it says its
> only for tdbcombobox.

> If there is an easy way, I'd be interested to hear it.
> Otherwise dont spend a lot of time responding to this.

> There usually is another way to do something.

> Thanks
> jim

Re:Tcombobox


You should try to change the index of the selected item insted of
chaging the text itself :
ComboBox.ItemIndex := 0;

Eoyore a crit :

Quote
> I have a Tcombobox on a form.
> At form activate event I fill the listbox.
> Then I use the code
> ComboBox1.Text := ComboBox1.Items[0];
> to specify a value.

> The problem is I have edit1 linked to the
> value in combobox1 and this doesnt fire the
> procedure TForm1.ComboBox1Change(Sender: TObject);

> I thought about messing with dropdown method I saw
> awhile back when browsing, but it says its
> only for tdbcombobox.

> If there is an easy way, I'd be interested to hear it.
> Otherwise dont spend a lot of time responding to this.

> There usually is another way to do something.

> Thanks
> jim

--
Sbastien MERIC
Ste Galbord,
23 rue Edouard Nieuport
92150 Suresnes
tl (+33) 1 44 14 15
fax (+33) 1 44 01 03

Re:Tcombobox


"Eoyore" <m...@slic.com> wrote
news:3949D3C5.D1FE6FA2@slic.com...

Quote
> I have a Tcombobox on a form.
> At form activate event I fill the listbox.
> Then I use the code
> ComboBox1.Text := ComboBox1.Items[0];
> to specify a value.

> The problem is I have edit1 linked to the
> value in combobox1 and this doesnt fire the
> procedure TForm1.ComboBox1Change(Sender: TObject);

Why not to fire the event by yourself after setting Text property - in code:
ComboBox1Change(ComboBox1);

I heard that this problem was fixed in newer versions of Delphi (4,5)

--
PSky

->p...@polbox.com
->p...@stud.ics.p.lodz.pl

Other Threads