RAD Studio VCL Reference
|
Occurs when the user opens the drop-down list.
property OnDropDown: TNotifyEvent;
__property TNotifyEvent OnDropDown;
Write an OnDropDown event handler to implement special processing that needs to occur only when the drop-down list is activated.
C++ Examples:
/* This example fills the list of a combo box with the set of open forms when the user drops down the list. The list is regenerated every time the list is dropped down, so if the application opens or closes forms, the combo box stays current. */ #include "Unit2.h" #include "Unit3.h" void __fastcall TForm1::ComboBox1DropDown(TObject *Sender) { ComboBox1->Items->BeginUpdate(); // prevent repaints until done ComboBox1->Items->Clear(); // empty the list of any old values for (int i = 0; i < Screen->CustomFormCount; i++) { if ((reinterpret_cast<TForm1 *>(Screen->CustomForms[i]))->Visible) ComboBox1->Items->Add(Screen->CustomForms[i]->Caption); // add form names } ComboBox1->Items->EndUpdate(); //reenable painting } void __fastcall TForm1::FormCreate(TObject *Sender) { ComboBox1->Sorted = True; // make sure the form names are sorted } void __fastcall TForm1::Button1Click(TObject *Sender) { Form2->Show(); } void __fastcall TForm1::Button2Click(TObject *Sender) { Form3->Show(); }
Delphi Examples:
{ This example fills the list of a combo box with the set of open forms when the user drops down the list. The list is regenerated every time the list is dropped down, so if the application opens or closes forms, the combo box stays current. } procedure TForm1.ComboBox1DropDown(Sender: TObject); var I: Integer; begin with ComboBox1 do begin Items.BeginUpdate; { prevent repaints until done } Items.Clear; { empty the list of any old values } for I := 0 to Screen.CustomFormCount - 1 do begin if (Screen.CustomForms[I].Visible) then Items.Add(Screen.CustomForms[I].Caption); { add form name } end; Items.EndUpdate; {reenable painting } end; end; procedure TForm1.FormCreate(Sender: TObject); begin ComboBox1.Sorted := True; { make sure the form names are sorted } end; procedure TForm1.Button1Click(Sender: TObject); begin Form2.Show; end; procedure TForm1.Button2Click(Sender: TObject); begin Form3.Show; end;
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|