CxGrid içerisinde kolonları TcxCurrencyEdit sahası yaptıgınızda RxCurrencyEdit gibi virgüllü giriş yaptırmak istiyorum.
Saygılarımla,
Recep MUT.
TcxCuerrencyEdit sahalarında RxCurrencyEdit Giriş tarzı
Forum kuralları
Forum kurallarını okuyup, uyunuz!
Forum kurallarını okuyup, uyunuz!
Merhaba,
arşivimde bu konuyla ilgili bir kod buldum gönderiyorum. Biri DevExpress Support'un gönderdiği kod, diğeri de yayınlayan elemanın düzenlediği hali.
Umarım faydası olur.
Kolay gelsin.
arşivimde bu konuyla ilgili bir kod buldum gönderiyorum. Biri DevExpress Support'un gönderdiği kod, diğeri de yayınlayan elemanın düzenlediği hali.
Umarım faydası olur.
Kolay gelsin.
Kod: Tümünü seç
procedure TForm1.cxGrid1DBTableView1TestPropertiesChange(Sender: TObject);
var
InputValue, NewValue: string;
DecimalSeparatorPos, I, L: Integer;
begin
with TcxCurrencyEdit(Sender) do
begin
Properties.OnChange := nil;
InputValue := EditingText;
NewValue := '';
DecimalSeparatorPos := 0;
for I := Length(InputValue) downto 1 do
if InputValue[I] in ['0'..'9', DecimalSeparator] then
begin
if InputValue[I] = DecimalSeparator then
DecimalSeparatorPos := Length(InputValue) - (I - 1);
L := Length(NewValue) - DecimalSeparatorPos;
if ((L mod 3) = (((L div 3)-1) mod 3)) and (L > 0) then
NewValue := ',' + NewValue;
NewValue := InputValue[I] + NewValue;
end;
Text := NewValue;
SelStart := MaxInt;
Properties.OnChange := cxGrid1DBTableView1TestPropertiesChange;
EditModified := True;
ModifiedAfterEnter := True;
end;
end;
--------------------------------
procedure TForm1.cxGrid1DBTableView1TestPropertiesChange(Sender: TObject);
var
InputValue, NewValue: string;
I: Integer;
begin
with TcxCurrencyEdit(Sender) do
begin
Properties.OnChange := nil;
InputValue := DelChars(EditingText,ThousandSeparator);
InputValue := DelChars(InputValue,DecimalSeparator);
NewValue := '';
for I := Length(InputValue) downto 1 do begin
If (Length(InputValue)-I) mod 3=0 Then NewValue:=ThousandSeparator+NewValue;
NewValue := InputValue[I] + NewValue;
end;
// There is one more thousand separator at the end of text, I remove it with the code below.
If Copy(NewValue,Length(NewValue),1)=ThousandSeparator Then NewValue:=Copy(NewValue,1,Length(NewValue)-1);
Text := NewValue;
SelStart := MaxInt;
Properties.OnChange := cxGrid1DBTableView1TestPropertiesChange;
EditModified := True;
ModifiedAfterEnter := True;
end;
end;