DELPHI7 ccombobox 文字水平居中

踏雪无痕 2013-05-26 12:52:40
这个我用空格移动在中间的,真麻烦,难道没有一个属性吗?
...全文
149 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
feiba7288 2013-05-27
  • 打赏
  • 举报
回复
引用 楼主 wozengcong 的回复:
这个我用空格移动在中间的,真麻烦,难道没有一个属性吗?
没有属性,要自己写重画事件OnDrawItem: 首先要设置ComboBox的Style属性为:csOwnerDrawVariable

procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
var
  ItemString: string;
begin
  TComboBox(Control).Canvas.FillRect(Rect);
  ItemString := TComboBox(Control).Items.Strings[Index];
  DrawText(TComboBox(Control).Canvas.Handle, PChar(ItemString), - 1, Rect, DT_CENTER);
end;

16,748

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧