如何让EDedit中的整形数居左?(50分)

  • 主题发起人 主题发起人 hongyizhujiao
  • 开始时间 开始时间
H

hongyizhujiao

Unregistered / Unconfirmed
GUEST, unregistred user!
我在编译后的dbedit中输入数值,为何总是显示在最右边,
如何才能让它显示在最左边?
 
自己做控件如TNumEdit
添加属性
property Alignment: TAlignment read FAlignment write SetAlignment default taRightJustify;

继承
procedure TNumEdit.CreateParams(var Params: TCreateParams);
const
Alignments: array[Boolean, TAlignment] of DWORD =
((ES_LEFT, ES_RIGHT, ES_CENTER), (ES_RIGHT, ES_LEFT, ES_CENTER));
begin
inherited CreateParams(Params);
with Params do Style := Style or Alignments[UseRightToLeftAlignment, FAlignment];
end;
实现
procedure TNumEdit.SetAlignment(Value: TAlignment);
begin
if FAlignment <> Value then
begin
FAlignment := Value;
RecreateWnd;
end;
end;
 
不用那么麻烦的,你打开和他连接的dataset,加入所有字段,
设置该字段的alignment属性就行了!
 
我不想加入全部字段,有些字段要在程序中实现,请问这种情况该如何实现?
 
呵呵,其实很简单。把对应的TField中的Alignment设为taLeftJustify就可以了。
 
多人接受答案了。
 
后退
顶部