• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 486
  • Last Modified:

To set Point on Tedit


Dear advisor !

I use Delphi 2005

On Change Event of Tedit i wrote :

lc    :=  Self.txtdaung.Text                          ;
lc    :=  StringReplace(lc, ',', '', [rfReplaceAll])  ;
lc    :=  FormatFloat('#,###,###,##0', StrToIntDef(lc, 0))  ;
Self.txtdaung.Text  := lc ;

This function means to change '12345' to '12,345' when inputing

i already Set BiDiMode = [bdRightToLeft] on Desigh
But when i input '1234', the point stand at '1' and the value of Tedit is '1,234' (as i thought) .

I want to set point at '4'

How to show this problem.

What i need , to change '12,345' to '12345' . So that function works well . But having trouble after input four charater, the point jump at the first charater. I need the point still at Right of Tedit

0
namcit99
Asked:
namcit99
1 Solution
 
pritaeasSoftware EngineerCommented:
BiDiMode is for right-to-left languages, like Hebrew. Not for aligning the text to the right.
Also, see the MaskEdit in the OLH.
0
 
mikelittlewoodCommented:
I presume that the string function still exists for delphi 2005, but you used to get over this problem by using the SelStart property

Set the position of SelStart to be the length of the text in the edit box.

Hope this helps

Please excuse the syntax, I havent done any delphi 2005 yet
    lc    := Self.txtdaung.Text;
    lc    :=  StringReplace(lc, ',', '', [rfReplaceAll])  ;
    lc    :=  FormatFloat('#,###,###,##0', StrToIntDef(lc, 0))  ;
    Self.txtdaung.Text := lc;
    Self.txtdaung.SelStart := Length(Self.txtdaung.Text)


This is what it would have been for Delphi 7
    lc    :=  (Sender as TEdit).Text;
    lc    :=  StringReplace(lc, ',', '', [rfReplaceAll])  ;
    lc    :=  FormatFloat('#,###,###,##0', StrToIntDef(lc, 0))  ;
    (Sender as TEdit).Text := lc;
    (Sender as TEdit).SelStart := Length((Sender as TEdit).Text)

0
 
calinutzCommented:
Delphi 7:
var
 lc:String;
begin
    lc    :=  (Sender as TEdit).Text;
    lc    :=  StringReplace(lc, ',', '', [rfReplaceAll])  ;
    lc    :=  FormatFloat('###,###,###,##0', StrToFloatDef(lc, 0))  ;
    (Sender as TEdit).Text := lc;
    (Sender as TEdit).SelStart := Length((Sender as TEdit).Text)
end;
0
 
calinutzCommented:
Do you only use it for integer values?
0
 
namcit99Author Commented:

Thank calinutz  !

But i use FloatToSTrF(StrToIntDEf(lc), ffNumber, 9, 0)

So i do not use your solution at  [lc    :=  FormatFloat('###,###,###,##0', StrToFloatDef(lc, 0))  ;]
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now