Mega Code Archive

 
Categories / Delphi / VCL
 

ComboBox drop down OnEnter

Title: ComboBox drop down OnEnter. Question: How to make the combobox drop down when you enter it with the tab key. Answer: unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; //This is just a component to tab from !! ComboBox1: TComboBox; procedure ComboBox1Enter(Sender: TObject); procedure ComboBox1Exit(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.ComboBox1Enter(Sender: TObject); begin SendMessage(ComboBox1.handle, CB_SHOWDROPDOWN, Integer(True), 0); end; procedure TForm1.ComboBox1Exit(Sender: TObject); //Drop-down close. begin SendMessage(ComboBox1.handle, CB_SHOWDROPDOWN, Integer(False), 0); end; end.