SynEdit 鼠标点击行号栏自动选中所在行

//CaretX 光标或鼠标所在行的列号(第几列),从0开始计数
//CaretY 光标或鼠标所在行的行号(第几行),从0开始计数
//SynEdit.Lines.Strings[]下标从0开始。要CaretY-1 设置LineNumberStart=0没用。
procedure TfrmLogin.sqlTextGutterClick(Sender: TObject; Button: TMouseButton; X, Y, Line: Integer; Mark: TSynEditMark);
begin
// ShowMessage(Format('CaretX:%d;CaretY:%d'+#13+'Line_Text:[%s]',[sqlText.CaretX,sqltext.CaretY,sqlText.Lines.Strings[sqltext.CaretY-1]]));
{ Memo控件可以采用下面的方法选中指定行,SynEdit无效,只能选中第一行。
sqlText.SelStart := SendMessage(sqlText.Handle, EM_LINEINDEX, sqltext.CaretY - 1, 0);
sqlText.SelLength := Length(sqlText.Lines[sqltext.CaretY - 1]); }
sqlText.SelLength := Length(sqlText.Lines.Strings[sqltext.CaretY-1]); //选中该行
end;

 

Memo 当前行号,坐标,位置

可以使用Memo的属性CaretPos.X来取行鼠标所在行的行数与鼠标所在行的第几位

Memo.CaretPos.X 光标或鼠标所在行的列号(第几位),从0开始计数
Memo.CaretPos.Y 光标或鼠标所在行的行号(位于Memo的第几行),从0开始计数

 

TBufferCoord  bc=synEditor1->CaretXY;

synEditor1->CaretX;
synEditor1->CaretY;

posted @   IT情深  阅读(62)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示