AvGSoft Цитата: В БД должно сохраняться как 12256589, а на экране 12\25; 65\89.
Попробуйте так
[more=pas, dfm]
Код: unit Unit10;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxGraphics, cxControls, cxLookAndFeels, cxLookAndFeelPainters, cxStyles, dxSkinsCore, dxSkinMcSkin,
dxSkinsDefaultPainters, dxSkinscxPCPainter, cxCustomData, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData,
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGridLevel, cxClasses, cxGridCustomView, cxGrid,
dxmdaset, cxNavigator, cxDBNavigator, cxMaskEdit;
type
TForm10 = class(TForm)
dxMemData1: TdxMemData;
dxMemData1Filed1: TStringField;
DataSource1: TDataSource;
cxGrid1DBTableView1: TcxGridDBTableView;
cxGrid1Level1: TcxGridLevel;
cxGrid1: TcxGrid;
cxGrid1DBTableView1RecId: TcxGridDBColumn;
cxGrid1DBTableView1Filed1: TcxGridDBColumn;
cxDBNavigator1: TcxDBNavigator;
procedure dxMemData1Filed1GetText(Sender: TField; var Text: string; DisplayText: Boolean);
procedure dxMemData1Filed1SetText(Sender: TField; const Text: string);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form10: TForm10;
implementation
{$R *.dfm}
procedure TForm10.dxMemData1Filed1GetText(Sender: TField; var Text: string; DisplayText: Boolean);
begin
if VarIsNull(Sender.Value) then Exit;
Text := VarToStr(Sender.Value);
Text := copy(Text, 1, 2) + '\' + copy(Text, 3, 2) + '; ' + copy(Text, 5, 2) + '\' + copy(Text, 7, 2);
end;
procedure TForm10.dxMemData1Filed1SetText(Sender: TField; const Text: string);
var
vText: string;
begin
vText := StringReplace(Text, '\', '', [rfReplaceAll]);
vText := StringReplace(vText, ';', '', [rfReplaceAll]);
vText := StringReplace(vText, ' ', '', [rfReplaceAll]);
Sender.Value := vText;
end;
end.