stringgrid中如何获得光标的位置?

ql_mf 2003-06-29 02:31:04
我要的不是row、col,而是在某个可编辑的cell中,光标的位置,类似于edit的selstart,可是stringgrid没有这个方法呀。
...全文
128 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
ql_mf 2003-07-01
  • 打赏
  • 举报
回复
after(橙) :
我试了试,虽然不太明白什么意思,不过真的可以呀。谢谢。
能具体讲解一下么?
afterchen 2003-07-01
  • 打赏
  • 举报
回复
试试这个吧!

HWND HEdit = FindWindowEx(StringGrid1->Handle, NULL,
"TInplaceEdit", NULL);
//送出信息,返回输入点所在的字符位置
long lPos = SNDMSG(HEdit, EM_GETSEL, NULL, NULL);
int iStart = LOWORD(lPos);
int iEnd = HIWORD(lPos);
Robin 2003-07-01
  • 打赏
  • 举报
回复
呵呵!
这样行不行!
你不是说有个row、col吗!
二合一不就是Cell的位置了吗!
afei2002 2003-07-01
  • 打赏
  • 举报
回复
用MSDN查一下看看有没有~~~
ql_mf 2003-07-01
  • 打赏
  • 举报
回复
我在cbuilder的帮助里怎么查不到SNDMSG这个函数呢?哪里有它的说明呢?
afterchen 2003-07-01
  • 打赏
  • 举报
回复
用FindWindowEx得到StringGrid中当前正处于编辑的单元格句柄(Edit),再对其发送消息得到选中串的开始位置和结束位置.(SNDMSG就是SendMessag)
Killmyself 2003-07-01
  • 打赏
  • 举报
回复
不懂,up
ql_mf 2003-06-30
  • 打赏
  • 举报
回复
没人知道么?
gfh21cn 2003-06-30
  • 打赏
  • 举报
回复
关注
这个问题提得好
ql_mf 2003-06-30
  • 打赏
  • 举报
回复
具体怎么做呢?
FlySky01 2003-06-30
  • 打赏
  • 举报
回复
放一个TEdit进去”是什么意思?
就是 用StringGrid 的框架,内容全部放在new出来的Edit中
Edit的位置刚好在StringGrid 的框架中。
当然
如果怕释放时候内存泄漏, 可以用个TEdit链表,释放可以统一管理

我想就是这个意思了
ql_mf 2003-06-30
  • 打赏
  • 举报
回复
winespirit(酒鬼) :
你说的:“放一个TEdit进去”是什么意思?
winespirit 2003-06-30
  • 打赏
  • 举报
回复
用StringGrid的Object属性,访问到哪个cell时放一个TEdit进去,就可以实现了
ql_mf 2003-06-29
  • 打赏
  • 举报
回复
不是我要的呀。
vc_hking 2003-06-29
  • 打赏
  • 举报
回复
//老程序摘的,自己看看吧,String Click事件中的代码
ComboBox1->Visible = true;
//StringGrid1->InsertControl(ComboBox1);
//StringGrid1->Cells[2][1] = ComboBox1->Text;


// test
char rBuf[10];
char cBuf[10];
itoa(StringGrid1->Col + 1, cBuf, 10);
itoa(StringGrid1->Row + 1, rBuf, 10);
Label1->Caption = String("The cursor is in column ") + String(cBuf) + String(", row ") + String(rBuf);
TRect rect;
int x;
int y;
x = StringGrid1->Col;
y = StringGrid1->Row;
rect = StringGrid1->CellRect(x,y);
//ShowMessage(String(x));
if (y % 2 == 0)
{
ComboBox1->Left = rect.Left +2 + 80*(1-x);
ComboBox1->Top = rect.Top + 24;
ComboBox1->Text = StringGrid1->Cells[1][y];
Edit1->Visible = false;
ComboBox1->Visible = true;
}
else
{
Edit1->Left = rect.Left +2 + 80*(1-x);
Edit1->Top = rect.Top + 24;
Edit1->Text = StringGrid1->Cells[1][y];
ComboBox1->Visible = false;
Edit1->Visible = true;
}

13,826

社区成员

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

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