请教两个小问题,请各位大哥指点一下:
1.怎样将edit组件里面的数据right justified,也就是说里面的数据显示在右边?
2.select * from EMGT.jpnpay_trans where  (rtrim(emp_code) = '+#39+dblookupcombobox1.KeyValue+#39+') and (rtrim(proc_month)='+spinedit2.text+'/'+spinedit1.Text+') order by emp_code(假设其中spinedit2.text='06',spinedit1.text='1999',数据库中的确有06/1999这条记录),但是运行这条SQL语句时会有错误出现,说什么SQL语句不能正常结束?
急请指教,谢谢!

解决方案 »

  1.   

    1.自己写个组件,然后添加到组件面板上中去:
    unit  MyEdit;  
     
    interface  
     
    uses  
       Controls,Windows,  Messages,  SysUtils,  Variants,  Classes,  Graphics,Forms,  Dialogs,  StdCtrls;  
     
     
    type  
       TMyEdit=class(TEdit)
       private  
           FAlignment:TAlignment;  
           procedure  SetAlignment(const  Value:  TAlignment);   protected
       public
          procedure  CreateParams(var  Params:TCreateParams);override;
       published
             property    Alignment:TAlignment  read  FAlignment  write  SetAlignment;  
       end;  
     
    procedure Register;implementation  
     
    {  TMyEdit  }  
    procedure Register;
    begin
      RegisterComponents('Samples', [TMyEdit]);
    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.  2.先用APPLICATION.MEEEAGEBOX把SQL输出来看看,估计还是出在SQL语句上
      

  2.   

    1.
    http://blog.csdn.net/li_zhifu/archive/2002/01/04/5466.aspx
    2.
    select * from EMGT.jpnpay_trans where  (rtrim(emp_code) = '+#39+dblookupcombobox1.KeyValue+#39+') and (rtrim(proc_month)='+spinedit2.text+'/'+spinedit1.Text+') order by emp_code
    //注意,proc_month被rtrim处理过,那就是说是String了,所以应该是这样
    select * from EMGT.jpnpay_trans where  (rtrim(emp_code) = '+#39+dblookupcombobox1.KeyValue+#39+') and (rtrim(proc_month)='''+spinedit2.text+'/'+spinedit1.Text+''') order by emp_code

    select * from EMGT.jpnpay_trans where  (rtrim(emp_code) = '+#39+dblookupcombobox1.KeyValue+#39+') and (rtrim(proc_month)='+#39+spinedit2.text+'/'+spinedit1.Text+#39+') order by emp_code
      

  3.   

    hi,must0001(飞鸟)
    请问怎样利用这段代码写个组件,然后添加到组件面板上中去,我是新手,不好意思,请多多指点!
      

  4.   

    1.1复制下列代码,存为REdit.pas
    //代码开始
    unit REdit;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls;type
      TCustomREdit = class(TCustomEdit)
      private
        { Private declarations }
        FAlignment:TAlignment;
        procedure SetAlignment(Value: TAlignment);
      protected
        { Protected declarations }
        property Alignment: TAlignment read FAlignment write SetAlignment default taLeftJustify;
        procedure CreateParams(var Params: TCreateParams); override;
      public
        { Public declarations }
      published
        { Published declarations }
      end;  TREdit = class(TCustomREdit)
      published
        { Published declarations }
        property Alignment;
        property Anchors;
        property AutoSelect;
        property AutoSize;
        property BiDiMode;
        property BorderStyle;
        property CharCase;
        property Color;
        property Constraints;
        property Ctl3D;
        property DragCursor;
        property DragKind;
        property DragMode;
        property Enabled;
        property Font;
        property HideSelection;
        property ImeMode;
        property ImeName;
        property MaxLength;
        property OEMConvert;
        property ParentBiDiMode;
        property ParentColor;
        property ParentCtl3D;
        property ParentFont;
        property ParentShowHint;
        property PasswordChar;
        property PopupMenu;
        property ReadOnly;
        property ShowHint;
        property TabOrder;
        property TabStop;
        property Text;
        property Visible;
        property OnChange;
        property OnClick;
        property OnContextPopup;
        property OnDblClick;
        property OnDragDrop;
        property OnDragOver;
        property OnEndDock;
        property OnEndDrag;
        property OnEnter;
        property OnExit;
        property OnKeyDown;
        property OnKeyPress;
        property OnKeyUp;
        property OnMouseDown;
        property OnMouseMove;
        property OnMouseUp;
        property OnStartDock;
        property OnStartDrag;
      end;procedure Register;implementationprocedure TCustomREdit.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
      begin
        Style := Style or Alignments[UseRightToLeftAlignment, FAlignment];
      end;
    end;procedure TCustomRedit.SetAlignment(Value:TAlignment);
    begin
      if FAlignment <> Value then
      begin
        FAlignment := Value;
        RecreateWnd;
      end;
    end;procedure Register;
    begin
      RegisterComponents('Samples', [TREdit]);
    end;end.
    //代码结束
      

  5.   

    1.2在Delphi中点Component|Install Component...
       在对话框中点击"Unit file name:"后的“Browse”按钮,选择刚存的redit.pas,点“OK”
       编译此包,在控件的Samples页中就会有了Redit控件
    2
    select * from EMGT.jpnpay_trans where  (rtrim(emp_code) = '+#39+dblookupcombobox1.KeyValue+#39+') and (rtrim(proc_month)='+spinedit2.text+'/'+spinedit1.Text+') order by emp_code
    --------------------------------------------------------------------
    //注意,proc_month被rtrim处理过,那就是说是String了,所以应该是这样select * from EMGT.jpnpay_trans where  (rtrim(emp_code) = '+#39+dblookupcombobox1.KeyValue+#39+') and (rtrim(proc_month)='''+spinedit2.text+'/'+spinedit1.Text+''') order by emp_code

    select * from EMGT.jpnpay_trans where  (rtrim(emp_code) = '+#39+dblookupcombobox1.KeyValue+#39+') and (rtrim(proc_month)='+#39+spinedit2.text+'/'+spinedit1.Text+#39+') order by emp_code