Advertisement
TLama

Untitled

Jun 19th, 2015
672
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.83 KB | None | 0 0
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.   ComboBox1.Clear;
  4.   ComboBox1.Style := csOwnerDrawFixed;
  5.   ComboBox1.Items.Add('cmd_estart=Entry start');
  6.   ComboBox1.Items.Add('cmd_eend=Entry End');
  7. end;
  8.  
  9. procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
  10. begin
  11.   TComboBox(Control).Canvas.FillRect(Rect);
  12.   if Index >= 0 then
  13.     TComboBox(Control).Canvas.TextOut(Rect.Left + 2, Rect.Top, TComboBox(Control).Items.ValueFromIndex[Index]);
  14. end;
  15.  
  16. procedure TForm1.Button1Click(Sender: TObject);
  17. var
  18.   ItemCommand: string;
  19.   ItemCaption: string;
  20. begin
  21.   ItemCommand := ComboBox1.Items.Names[ComboBox1.ItemIndex];
  22.   ItemCaption := ComboBox1.Items.ValueFromIndex[ComboBox1.ItemIndex];
  23.   ShowMessage(Format('Command: %s; Caption: %s', [ItemCommand, ItemCaption]));
  24. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement