Arsip: Combo Box

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...

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

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 -
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 ..

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
reply |
Report Obsolete
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
Last Articles
Last Topic
- PascalTalk #6: (Podcast) Kuliah IT di luar negeri, susah gak sih?
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #5: UX: Research, Design and Engineer
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #4: Obrolan Ringan Seputar IT
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #2: Membuat Sendiri SMART HOME
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #3: RADically Fast and Easy Mobile Apps Development with Delphi
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #1: Pemanfaatan Artificial Intelligence di Masa Covid-19
by LuriDarmawan in Tutorial & Community Project more 4 years ago - Tempat Latihan Posting
by LuriDarmawan in OOT more 5 years ago - Archive
- Looping lagi...
by idhiel in Hal umum tentang Pascal Indonesia more 12 years ago - [ask] koneksi ke ODBC user Dsn saat runtime dengan ado
by halimanh in FireBird more 12 years ago - Validasi menggunakan data tanggal
by mas_kofa in Hal umum tentang Pascal Indonesia more 12 years ago
Random Topic
- treeview load dari database?
by alvonz in OOT more 16 years ago - [tanya] gmana cara buat bar code
by charlie in Hal umum tentang Pascal Indonesia more 18 years ago - Point Gateway (SMS Gateway)
by eksant in Free dan Gratis more 14 years ago - kalendar dalam tahun
by vera in Tip n Trik Pemrograman more 16 years ago - bagaimana cara membaca data sensor ke delphi
by w4rek in Network, Files, I/O & System more 17 years ago - Pencarian dg 2 parameter?
by rose_see in MySQL more 17 years ago - System Stanby
by supermuam in Hal umum tentang Pascal Indonesia more 15 years ago - jangan edit posting
by LuriDarmawan in Moderator Only more 17 years ago - [?] Dimana Mendefinisikan Variabel di FastReport BeforePrint
by babypigs in Bedah Kasus more 17 years ago - App Pemesanan Makanan, Multiuser atau Client Server ?
by echo_crazz in Network, Files, I/O & System more 13 years ago