Articles   Members Online: 3
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to position the cursor on the right-hand side of a TEdit Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
27-Aug-02
Category
VCL-General
Language
Delphi 2.x
Views
84
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

I want to write an Edit component, but I want the cursor to stay on the right when 
the user types in new characters.

Answer:

1   procedure TForm1.Edit1Change(Sender: TObject);
2   begin
3     if IsChanging then
4       exit; {Avoid recursion}
5     IsChanging := true;
6     try
7       {Remove the first character}
8       Edit1.Text := copy(Edit1.Text, 2, length(Edit1.Text) - 1);
9       {And move the cursor to the end of the text}
10      Edit1.SelStart := length(Edit1.Text);
11    finally
12      IsChanging := false;
13    end;
14  end;


At design time (or in Create), put several spaces as Edit1.Text. They will be replaced one by one with characters typed by the user. IsChanging is a private variable of type boolean.

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC