Arsip: Combo Box

 
user image
more 18 years ago

pegal_linux

Hola Programmador, Ada yang bisa kasih contoh source code untuk membuat combo yang isi dropdownnya berupa tabel. Pokoknya ada sheet gitu. Aku pernah liat temanku membuatnya dengan Qt dan Python untuk program di Linux. Belakangan aku juga mendapatkan OCX yang gituan tapi hanya untuk VB dan aku coba load dengan delphi tidak bisa. Apa ada yang bisa buat dengan delphi ?. Sebelumnya Terima Kasih...
user image
more 18 years ago

Kecret

maksudnya berisi tabel gimana sich.... apa combo tsb berisi daftar tabel? ... ada screenshootnya?
user image
more 18 years ago

Kecret

apa maksudnya begini:
user image
more 18 years ago

chipmunk

Klo mo yang bener2 OK dan reusable perlu nulis komponen from the scratch...ato inherit dari yg uda ada.. Tapi klo pake per aplikasi aja dan murah :D ..coba codes berikut ini yg bisa nampilin combo box lumayan beda: Ini adalah TComboBox biasa dg property: Style : OwnerDrawFixed Event(s): OnDrawItem Untuk pake codes-nya, coba extract sendiri dari cuplikan ini... :wink:
unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Contnrs, StdCtrls;
type
  TMyItem = class
  private
    FLovePet: Boolean;
    FExp: String;
    FName: String;
  public
    constructor Create(const AFullName,AExpertises: String; const IsLovePet: Boolean);
    property FullName: String read FName write FName;
    property Expertises: String read FExp write FExp;
    property LovePet: Boolean read FLovePet write FLovePet;
  end;
  TForm1 = class(TForm)
    ComboBox1: TComboBox;
    procedure FormCreate(Sender: TObject);
    procedure ComboBox1DrawItem(Control: TWinControl; Index: Integer;
      Rect: TRect; State: TOwnerDrawState);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
implementation
{$R .dfm}
{ TMyItem }
constructor TMyItem.Create(const AFullName, AExpertises: String;
  const IsLovePet: Boolean);
begin
  FLovePet := IsLovePet;
  FName := AFullName;
  FExp := AExpertises;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
  SendMessage(ComboBox1.Handle, CB_SETDROPPEDWIDTH, ComboBox1.Width 4,0);
  with ComboBox1.Items do
  begin
    AddObject('Malang', TMyItem.Create('Chipmunk','Delphi, C/C++, C#',true));
    AddObject('Surabaya', TMyItem.Create('Anders Heijelberg','Delphi, C/C++, C#',false));
    AddObject('Kediri', TMyItem.Create('David Intersimone','Delphi, C/C++, C#',true));
    AddObject('Blitar', TMyItem.Create('Revalina','Sunda, Betawi',false));
  end;
end;
procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
var
  item: TMyItem;
  R: TRect;
  i: Integer;
  tmp: array of String;
begin
  item := TCustomComboBox(Control).Items.Objects[Index] as TMyItem;
  tmp[0] := TCustomComboBox(Control).Items[Index];
  tmp[1] := item.FullName;
  tmp[2] := item.Expertises;
  with TCustomComboBox(Control).Canvas do
  begin
    Font.Assign(ComboBox1.Font);
    if odSelected in State then
      Font.Color := clHighlightText
    else
      Font.Color := clWindowText;
    R := Rect;
    R.Right := TCustomComboBox(Control).Width;
    FillRect(Rect);
    for i := 0 to 2 do
    begin
      if i = 0 then Font.Style := Font.Style + [fsBold]
      else Font.Style := Font.Style - [fsBold];
      DrawEdge(Handle,R,BDR_RAISEDINNER,BF_LEFT or BF_FLAT);
      InflateRect(R,-2,0);
      DrawText(Handle, PChar(tmp[i]),Length(tmp[i]),R, DT_LEFT or DT_VCENTER or DT_SINGLELINE or DT_END_ELLIPSIS);
      InflateRect(R,2,0);
      OffsetRect(R,R.Right-R.Left,0);
    end;
    InflateRect(R, -1,-1);
    R.Right := R.Left + (R.Bottom - R.Top);
    if item.LovePet then
      DrawFrameControl(Handle, R, DFC_BUTTON, DFCS_CHECKED or DFCS_FLAT)
    else
      DrawFrameControl(Handle, R, DFC_BUTTON,DFCS_FLAT);
    OffsetRect(R,20,0);
    R.Right := Rect.Right;
    tmp[0] := 'Love Pet';
    DrawText(Handle, PChar(tmp[0]),Length(tmp[0]),R, DT_LEFT or DT_VCENTER or DT_SINGLELINE or DT_END_ELLIPSIS);
  end;
end;

end.
Seperti biasanya, codes ini hanya proof of concept aja.. silakan kembangkan sendiri.. - chipmunk -
user image
more 18 years ago

tox2wow

maksudnya berisi tabel gimana sich.... apa combo tsb berisi daftar tabel? ... ada screenshootnya?
Mungkin maksudnya, combo box kaya komponen TDateTimePicker, tapi item combo box-nya mengacu ke tabel yg ada .. gitu kali ya ... :D ... sory kalo salah ..
user image
more 18 years ago

pegal_linux

Thankx.... Kodenya OK banget :lol: Nanti akan aku coba untuk buat menjadi sebuah komponen. Thankx my community
more ...
  • Pages:
  • 1
Share to

AI Forward

🚀 We're thrilled to partner with Alibaba Cloud for "AI Forward - Alibaba Cloud Global Developer Summit 2025" in Jakarta! Join us and explore the future of AI. Register now: https://int.alibabacloud.com/m/1000400772/
#AlibabaCloud #DeveloperSummit #Jakarta #AIFORWARD

Local Business Directory, Search Engine Submission & SEO Tools FreeWebSubmission.com SonicRun.com