Articles   Members Online:
-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 reposition the cursor in 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 All Versions
Views
89
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

How to reposition the cursor in a TEdit

Answer:

The example below uses two TEdit's:

1   unit Cursor;
2   
3   interface
4   
5   uses
6     SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
7     Forms, Dialogs, StdCtrls;
8   
9   type
10    TForm1 = class(TForm)
11      Edit1: TEdit;
12      Edit2: TEdit;
13      procedure Edit1Change(Sender: TObject);
14      procedure Edit1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
15    private
16      { Private declarations }
17    public
18      { Public declarations }
19      CurPos: integer;
20    end;
21  
22  var
23    Form1: TForm1;
24  
25  implementation
26  
27  {$R *.DFM}
28  
29  procedure TForm1.Edit1Change(Sender: TObject);
30  begin
31    CurPos := Edit1.SelStart;
32    edit2.Text := IntToStr(CurPos);
33  end;
34  
35  procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
36  begin
37    if Key = VK_LEFT then
38      dec(CurPos);
39    if Key = VK_RIGHT then
40      inc(CurPos); {Right Arrow}
41    edit2.text := inttostr(CurPos);
42  end;
43  
44  end.


			
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