combobox和listbox的文字可以右对齐显示
来源:互联网 发布:c语言中swap的用法 编辑:程序博客网 时间:2024/06/11 02:00
combobox和listbox的文字可以右对齐显示么?答案是可以的,但是必须使用ComboBox1DrawItem,自行画内容。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
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}
procedure TForm1.FormCreate(Sender: TObject);
begin
ComboBox1.Style := csOwnerDrawFixed;
end;
procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
var
x: Integer;
txt: string;
begin
with ComboBox1 do
begin
Canvas.FillRect(Rect); //将combobox用现在的brush填充颜色
txt := Items[Index];
x := Rect.Right - Canvas.TextWidth(txt) - 4;
Canvas.TextOut(x, Rect.Top, txt);
end;
end;
end.
- combobox和listbox的文字可以右对齐显示
- html使用display:inline-block实现标签右对齐,值左对齐效果。和设置div宽度,并居中显示。嵌套div的里层div文字居中显示
- Canvas_Textout_文字右对齐
- ListBox 和 ComboBox 控件
- 图片和文字同行显示时的垂直对齐方式
- QLabel属性 文字右对齐
- 获取其他进程中ListBox和ComboBox的内容
- 如何检测listbox和combobox里面重复的值?
- 获取其他进程中ListBox和ComboBox的内容
- 图片和文字的对齐
- LinearLayout和Relativelayout的右对齐问题
- 左对齐和右对齐
- QMessageBox 显示文字对齐的实现
- 实现TStringGrid的左对齐、居中和右对齐
- 设置edit右对齐显示
- 如何调整UIButton里面的文字位置以及按钮文字右对齐
- 如何调整UIButton里面的文字位置以及按钮文字右对齐
- 如何调整UIButton里面的文字位置以及按钮文字右对齐
- 写一个服务程序的模板
- 开始→运行→输入的命令集锦
- 在消息窗口中显示进度条
- 代码在线烧录注意的一点
- Java 多线程编程之一 进程与线程,并发和并行的区别:吃馒头的比喻
- combobox和listbox的文字可以右对齐显示
- 五种JSP跳转方式比较
- delphi的资源文件
- pos、ansipos、fillchar在delphi2010中unicode的问题
- 博弈问题及SG函数(真的很经典)
- .NET正则基础之——正则委托
- fasdfasdfaaaaaaaaaa
- hibernate一对一关联映射
- XP 极限编程