Hello, you have to set this mask on the visual component to be used to display the field, for example the "Passwordchar" property of a Tdbedit / Tedit, by default the field’s default value is "#0", you must change it to "*" or any other character you wish to use as a mask.
Edited:
You will need to inherit the Tstring List class in your own class:
TMyGrid = class(TStringGrid)
protected
function CreateEditor: TInplaceEdit; override;
procedure DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState); override;
end;
And then implement the redeclared methods:
function TMyGrid.CreateEditor: TInplaceEdit;
begin
Result := TInplaceEdit.Create(Self);
if (Passwd) then
TMaskEdit(Result).PasswordChar := '*';
end;
procedure TMyGrid.DrawCell(ACol, ARow: Integer; ARect: TRect;
AState: TGridDrawState);
begin
if (Passwd) then
Canvas.TextRect(ARect, ARect.Left+2, ARect.Top+2, StringOfChar('*', Length(Cells[ACol, ARow])))
else
Canvas.TextRect(ARect, ARect.Left+2, ARect.Top+2, Cells[ACol, ARow]);
end;
and then you can use your custom Tstringgrid:
meuGrid := TMyGrid.Create(Self);
meuGrid.Parent := Self;
meuGrid.Left := 5;
meuGrid.Top := 5;
meuGrid.Width := 400;
meuGrid.Height := 400;
meuGrid.Options := meuGrid.Options + [goEditing];
Then it will work, you just need to define the logic of the variable "Passwd"
Hugs.
this in the component, but I’m wanting to format in a stringgrid
– Jefferson Mello Olynyki
It’s a little complicated, but I edited the answer, take a look there...
– Dennis