To set Point on Tedit

Posted on 2005-05-10
Medium Priority
Last Modified: 2010-04-04

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

Question by:namcit99

Expert Comment

ID: 13975987
BiDiMode is for right-to-left languages, like Hebrew. Not for aligning the text to the right.
Also, see the MaskEdit in the OLH.
LVL 15

Accepted Solution

mikelittlewood earned 80 total points
ID: 13975989
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)

LVL 11

Expert Comment

ID: 13976106
Delphi 7:
    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)
LVL 11

Expert Comment

ID: 13976137
Do you only use it for integer values?

Author Comment

ID: 13983516

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))  ;]

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question