怎么在一个COMBOBOX的控件里的每一个ITEM前面加一个图标?
解决方案 »
- 在窗体上加横线的问题
- Dll中封装非模态窗体的问题?
- 帮我看看这个SQL语句是不是不太好,每次查询都是提示超时
- 怎样将delphi编出程序的默认图标改成自已定义的?
- GIS中最短路径算法问题(MapX + Delphi7)
- 各位大侠帮帮小弟,这样的动态库函数如何调用(C语言写的),在线等!!!!!!!!!!!!
- ▲▲▲▲▲还是关于TSGRID的一个简单问题(高分)▲▲▲▲
- Tchart中如何动态添加设置饼形图的labels属性呢?
- 哪里有InstallShield Express的中文包D6自带的那个。
- 我想在一个变量比方T,前后都加个'号赋给另外一个变量比方S,好用SQL语句查询,
- ADOConection连接Access问题
- 在服务程序里面如何记录键盘输入?
OnMeMeasureItem事件中设置高度
procedure TForm1.CBBoxDrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
var
lrc,rrc:TRect;
bc:TColor;
begin
with CBBox.Canvas do
begin
bc:=Brush.color;
Brush.color:=clRed;
lrc.left:=rect.left;
lrc.right:=20;
lrc.Top:=rect.Top;
lrc.Bottom:=rect.Bottom;
rrc.Left:=20;
rrc.Right:=rect.right;
rrc.Top:=rect.Top;
rrc.Bottom:=rect.bottom;
FillRect(lrc);
if odSelected in State then Brush.color:=clLime
else Brush.color:=clWhite;
FillRect(rrc);
Brush.color:=bc;
Brush.Style:=bsClear;
TextOut(26,Index*CBBox.ItemHeight+2,CBBox.Items.Strings[Index]);
end;
end;
Rect: TRect; State: TOwnerDrawState);
var
text : string;
off : integer;
i,N : integer;
begin
N :=0;
for i :=0 to Combobox2.Items.Count - 1 do
begin
if ComboBox2.Items[i] = 'D' then
N :=i - 2;
end; ComboBox1.Canvas.FillRect( Rect );
if Index <= N then
ImageList6.Draw(combobox1.canvas,Rect.left+2,Rect.top+2,0)
else
ImageList6.Draw(combobox1.canvas,Rect.left+2,Rect.top+2,1);
text :=combobox1.items.Strings[Index];
off :=Trunc((Rect.bottom - Rect.top- combobox1.Canvas.TextHeight(text))/2);
combobox1.Canvas.TextOut(Rect.left+imagelist6.width+2*2,Rect.top+off,text);
設定:ComboBoxEx1.Images := ImageList1;
把图标装入ImageList1中...