1.如何把bitbtn组件放进Panel内?如果是选创建bitbtn.
2.如何设置dbedit组件中的文字的对齐方式?比如左对齐,右对齐

解决方案 »

  1.   

    1:程序执行时BitBtn.Parent:=Panel,开发环境中,Copy & Paste2:重载CreateParams,给Params.Style加上[FAlignment],Params.Style := Params.Style + [FAlignment];
      

  2.   

    Alignments : array[TAlignment] of LongWord= (ES_LEFT, ES_RIGHT, ES_CENTER);
      

  3.   

    http://expert.csdn.net/Expert/topic/1112/1112253.xml
    http://expert.csdn.net/Expert/topic/1489/1489131.xml论坛中搜索...
      

  4.   

    为什么运行这个会出现错误?unit MyEdit;interfaceuses
      Controls,Windows, Messages, SysUtils, Variants, Classes, Graphics,Forms, Dialogs, StdCtrls;
    type
      TMyEdit=class(TEdit)
      private
        FAlignment:TAlignment;
        procedure SetAlignment(const Value: TAlignment);
        procedure CreateParams(var Params:TCreateParams);override;
      protected
      published
         property  Alignment:TAlignment read FAlignment write SetAlignment;
      end;
    implementation{ TMyEdit }constructor TMyEdit.Create(AOwner: TComponent);
    begin
      inherited;end;procedure TMyEdit.CreateParams(var Params: TCreateParams);
    begin
      inherited;
      case FAlignment of
        taLeftJustify:
          begin
            Params.Style := Params.Style + ES_LEFT;
          end;
        taRightJustify:
          begin
            Params.Style := Params.Style + ES_RIGHT;
          end;
        taCenter:
          begin
            Params.Style := Params.Style + ES_CENTER;
          end;
      end;
    end;
    procedure TMyEdit.SetAlignment(const Value: TAlignment);
    begin
      if FAlignment<>Value then
      begin
        FAlignment := Value;
        RecreateWnd;
      end;
    end;
    end.---------------
    uses MyEdit;procedure TForm1.Button1Click(Sender: TObject);
    var
      MyEdit:TMyEdit;
    begin
      MyEdit:=TMyEdit.Create(Form1);
      MyEdit.Alignment:=taCenter;
      MyEdit.Parent:=Form1;
    end;我是新建一个application然后把上面的代码copy进去运行的。