Re: Arriving to max field size
From: Guillem (guillemvicens_at_clubgreenoasis.com)
Date: 02/09/05
- Next message: Star: "Re: Properties PageSize and AbsolutePage in TADODataSet"
- Previous message: Olo1973: "Re: BDE, ADO..."
- In reply to: Dennis: "Re: Arriving to max field size"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 9 Feb 2005 15:35:19 +0100
Hi,
tried this code but got 2 issues:
1 - When I arrive to fOldValue := fOldField.Value; in the KeyPress
function, after changing of field I always get an exception telling me "Can
not convert boolean to string". Why? I'm not using any booleans at all. I
have only varchar fields.
2 - I have noticed that if in my database a field has, for example, size 4,
fOldField.Datasize will return 5. Is this normal???
I'm using MySQL 4.01 if that helps in any way
--
Best regards
Guillem Vicens
Dep. informática Green Service SA
guillemvicens@clubgreenoasis.com
www.clubgreenoasis.com
<Dennis Passmore> escribió en el mensaje
news:u37f0157nl0kopjtchus9jpl7p86pla3a6@4ax.com...
> Just create a runtime override TInplaceEdit as follows and apply whatever
> rules you want
> in the override KeyPress procedure.
>
> type
> TcInplaceEdit = class(TInplaceEdit)
> private
> fOldRecNo: integer;
> fOldField: TField;
> fOldValue: variant;
> protected
> procedure KeyPress(var Key: Char); override;
> end;
>
> TDBGrid = class(DBGrids.TDBGrid)
> private
> protected
> function CreateEditor: TInplaceEdit; override;
> end;
>
> TForm1 = class(TForm)
> Query1: TQuery;
> Database1: TDatabase;
> DBGrid1: TDBGrid;
> DataSource1: TDataSource;
> private
> { Private declarations }
> public
> { Public declarations }
> end;
>
> var
> Form1: TForm1;
>
> implementation
>
> {$R *.dfm}
>
> { TcInplaceEdit }
>
> procedure TcInplaceEdit.KeyPress(var Key: Char);
> begin
> with TDbGrid(Grid) do
> if (fOldRecNo <> DataSource.DataSet.RecNo) or
> (SelectedField <> fOldField) then
> begin
> fOldRecNo := TDbGrid(Grid).DataSource.Dataset.RecNo;
> fOldField := TDbGrid(Grid).SelectedField;
> fOldValue := fOldField.Value;
> end;
> if (length(Text) = fOldField.DataSize) and
> not(Key in [chr(27),chr(13),chr(9),chr(8)]) then
> begin
> beep;
> key := #0;
> end
> else
> inherited;
> end;
>
> { TDBGrid }
>
> function TDBGrid.CreateEditor: TInplaceEdit;
> begin
> result := TcInplaceEdit.Create(Self);
> end;
>
>
> Dennis Passmore
> Ultimate Software, Inc.
- Next message: Star: "Re: Properties PageSize and AbsolutePage in TADODataSet"
- Previous message: Olo1973: "Re: BDE, ADO..."
- In reply to: Dennis: "Re: Arriving to max field size"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|