请问:有什么下拉列表控件,显示的是名称,下拉时可以看到代码和名称,保存到数据库中是代码?多谢!(50)

  • 主题发起人 Sdelphi_fu
  • 开始时间
S

Sdelphi_fu

Unregistered / Unconfirmed
GUEST, unregistred user!
Z

zbdzjx

Unregistered / Unconfirmed
GUEST, unregistred user!
象金蝶那样???据我感觉,在金蝶中应该是显示时是一个label,当鼠标点label时,label隐藏,显示一个edit也可以是一个lookupcombobox,下拉时显示代码和名称,保存到数据库中是代码,当鼠标从edit或是lookupcombobox中离开时,执行onexit事件,将edit或是lookupcombobox隐藏,显示label,label中显示名称。
 
H

hs-kill

Unregistered / Unconfirmed
GUEST, unregistred user!
combobox里自己画呗type TForm1 = class(TForm) ComboBox1: TComboBox; procedure FormCreate(Sender: TObject); procedure ComboBox1DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); private { Private declarations } al:array of array[0..1] of string; public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);var w, h, i:integer; str:string;begin with TCombobox(Control) do begin Canvas.FillRect(rect); i:=integer(Items.Objects[Index]); if odComboBoxEdit in State then str:=Format('%s', [al[0]]) else str:=Format('%s / %s', [al[0], al[1]]); w:=Canvas.TextWidth(str); h:=Canvas.TextHeight(str); Canvas.TextOut(rect.Left+2, rect.Top+(Rect.Bottom-Rect.Top-h) div 2, str); end;end;procedure TForm1.FormCreate(Sender: TObject);var i:integer;begin setlength(al, 9); for i := 0 to 9 do begin al[0]:='字符'+inttostr(i); al[1]:='代码'+inttostr(i); ComboBox1.Items.AddObject(al[0], TObject(i)); end; ComboBox1.Style:=csOwnerDrawFixed;end;end.
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
1K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
917
SUNSTONE的Delphi笔记
S
顶部