解决方案 »
- ADOQuery问题
- Delphi与西门子S7-300通过以太网通讯
- ADO一个很有意思的问题,关于“无法为更新定位行...”
- 如何查询ACCESS表中的信息:字段名称,数据类型,说明.
- 一个很奇怪的问题,很有意思的....
- DLL 调用TCLIENTSOCKET onread 事件
- 高手请进:那里有使用起来很方便的TREELIST或TREEVIEW控间吗?
- 能否把客户端数据集的delta直接赋给数据集提供者?200分!!!
- 怎样使按Ctrl+S时,执行某个动作?
- 有谁知道从哪里可以下载TopGrid for cb的带源码的控件包呢?拜托,很着急!!!
- 在线等,请问读取utf-16的xml变utf-8而且中文乱码问题
- 新浪微博加密
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;type
TForm1 = class(TForm)
RichEdit1: TRichEdit;
Edit1: TEdit;
procedure RichEdit1KeyPress(Sender: TObject; var Key: Char);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
richedit1.Text:='';
end;procedure TForm1.RichEdit1KeyPress(Sender: TObject; var Key: Char);
var i,k :integer;
s,ls:string;
begin
if key=#13 then
begin
key:=#0;
if richedit1.Lines.Count<1 then exit;
if richedit1.Lines.Count>0 then i:=richedit1.Lines.Count-1;
s:=richedit1.Lines.Strings[i];
k:=pos('=',s);
ls:=copy(s,1,k);
richedit1.Lines.Add(ls);
edit1.Text:=inttostr(richedit1.Lines.Count);
richedit1.SelStart:=length(richedit1.Text);
richedit1.SelLength:=0;
richedit1.SetFocus;
end;
end;end.
procedure TForm1.RichEdit1KeyPress(Sender: TObject; var Key: Char);
var i,k :integer;
s,ls:string;
begin
if key=#13 then
begin
key:=#0;
if richedit1.Lines.Count<1 then exit;
i:=richedit1.Lines.Count-1;
s:=richedit1.Lines.Strings[i];
k:=pos('=',s);
ls:=copy(s,1,k);
richedit1.Lines.Add(ls);
edit1.Text:=inttostr(richedit1.Lines.Count);
richedit1.SelStart:=length(richedit1.Text);
richedit1.SelLength:=0;
richedit1.SetFocus;
end;
end;
procedure TForm1.RichEdit1KeyPress(Sender: TObject; var Key: Char);
var i,k :integer;
s,ls:string;
begin
if key=#13 then//如果回车键被按下了
begin
key:=#0;//把回车的动作消掉
if richedit1.Lines.Count<1 then exit;//如果richedit1没内容,不往下执行
i:=richedit1.Lines.Count-1;//取最后一行的索引值
s:=richedit1.Lines.Strings[i];//取最后一行的字符
k:=pos('=',s);//求等号在字符串的位置
ls:=copy(s,1,k);//从字符串第一个开始、复制到(包括)等号
richedit1.Lines.Add(ls);//将刚复制的字符串添加进richedit1内
edit1.Text:=inttostr(richedit1.Lines.Count);//在edit1中显示richedit1的行数
richedit1.SelStart:=length(richedit1.Text);//选择的起始位
richedit1.SelLength:=0;//选择字符的个数
richedit1.SetFocus;//让richedit1获得焦点
end;
end;
谢谢楼上两位,结贴,散发。另外,麻烦你们谁去点击下这个,帖子没用顶,结贴不了。谢谢
http://topic.csdn.net/u/20110909/01/7bda7a33-2b9e-4af9-a794-7a8c751ce046.html