如何让光标停在MEMO的指定位置?

wangsj 2003-05-14 08:11:04

想在MEMO中间加入字符串,如:
select (amt1) from table where x='sdsdsd' and

鼠标先放这里,然后按个自制的[Sum]按纽,将字符串"Sum"加入变成:
select sum(amt1) from table where x='sdsdsd' and

然而加入后光标却回到了第一行的左边

select sum(amt1) from table where x='sdsdsd' and

我想让光标留在“sum”后面。

★★如何让光标停在MEMO的指定位置?

如何加入"sum"?见
http://expert.csdn.net/Expert/topic/1779/1779031.xml?temp=.3438227
...全文
87 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
wangsj 2003-05-14
  • 打赏
  • 举报
回复
Libran上次已经告诉我过了 Memo1->SelStart,我怎么.....
wangsj 2003-05-14
  • 打赏
  • 举报
回复
我不得不承认:我愚蠢透顶!
Libran 2003-05-14
  • 打赏
  • 举报
回复
在按钮事件里写:
int pos = Memo1->SelStart;
AnsiString s = "sum"; //这里指定要插入的内容
Memo1->Text = Memo1->Text.SubString(1, pos)+
s+Memo1->Text.SubString(pos+1, Memo1->Text.Length()-pos);
Memo1->SelStart = pos + s.Length();
Memo1->SetFocus();

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧