我不想在字段编辑器中创建永性字段,但又想在onGettext中写代码
通过如"ClientDataSet.fields[0].onGettext"这样的方式来调用gettext事件,不知可行否?如果行我应该如何来定义过程?谢谢!

解决方案 »

  1.   

    procedure TForm1.GetText(Sender: TField; var Text: String;
      DisplayText: Boolean);
    begin
      Text := Text + 'abc';
    end;ClientDataSet.fields[0].onGettext := GetText;试试!
      

  2.   

    to chenzhuo 
    肯定不行ClientDataSet.fields[0].onGettext是TFieldGetTextEvent类的.
    我想能不能定义一个TFieldGetTextEvent类的过程.可是就是不知道有没有这种用法?
      

  3.   

    Hola. No hace falta gritar tan alto.Basta presionar F1 dentro del IDE. :mad:
    Occurs whenever the DisplayText or Text properties of the field are referenced.type TFieldGetTextEvent = procedure(Sender: TField; var Text: string; DisplayText: Boolean) of object;
    property OnGetText: TFieldGetTextEvent;DescriptionWrite an OnGetText handler to perform custom processing for the DisplayText and Text properties. Use OnGetText to format the Value of the field differently when it must be edited from the format used when simply displaying the value, or use OnGetText to display something other than the field’s value when it is displayed.The Sender parameter is the field component. The Text parameter receives the formatted text that is used by the DisplayText or Text property. The DisplayText parameter indicates whether the text will be used for display purposes only, or whether the string will be used for editing purposes.If there is no OnGetText handler, the value of the DisplayText and Text properties is simply the value of the AsString property.
    Hasta luego.
      

  4.   


    Occurs whenever the DisplayText or Text properties of the field are referenced. type TFieldGetTextEvent = procedure(Sender: TField; var Text: string; DisplayText: Boolean) of object; 
    property OnGetText: TFieldGetTextEvent;