在线等待:如何调用StringGrid控件的DrawCell事件? 紧急!!!!!!!!!!

skyclin 2003-01-08 05:07:42
是这样的:
  在StringGrid控件中嵌入一个combobox控件!当A列被选中后,combobx控件才显示出来!当用鍵盘上的向左光标键调节到A列时,combobox控件没显示出来?
我不知道为什么?
...全文
228 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
noall 2003-01-28
  • 打赏
  • 举报
回复
在SelectCell事件里写.
这样
if acol=1 then
begin

Button1.Left :=stringgrid1.left+stringgrid1.CellRect(ACol,arow).Left;
Button1.Top :=stringgrid1.Top+stringgrid1.CellRect(ACol,arow).top;
button1.Visible :=true;
end else
button1.Visible :=false;
noall 2003-01-28
  • 打赏
  • 举报
回复
在selectcell事件里判断
并用stringgrid1.Selection.属性固定位置。
Billy_Chen28 2003-01-28
  • 打赏
  • 举报
回复
错了,重来:
procedure TSTRINGGRID.DrawCell(...);
begin
if Assigned(FOnDrawCell) then FOnDrawCell(Self);
end;

const
DrawCell = WM_USER + 1;

procedure STRINGGRID(var Msg: TMessage); message STRINGGRID;
...

procedure TSTRINGGRID.DrawCell(var Msg: TMessage);
begin
DrawCell;
end;
Billy_Chen28 2003-01-28
  • 打赏
  • 举报
回复
如果实在不行,你可以定义一个消息:

const
DrawCell = WM_USER + 1;

procedure STRINGGRID(var Msg: TMessage); message FHLM_STRINGGRID;
...

procedure STRINGGRID.DrawCell(var Msg: TMessage);
begin
DrawCell;
end;

goease 2003-01-28
  • 打赏
  • 举报
回复
在SelectCell中写
outer2000 2003-01-08
  • 打赏
  • 举报
回复
procedure TForm1.StringGrid1Enter(Sender: TObject);
begin
//here your code is ok;
end;
skyclin 2003-01-08
  • 打赏
  • 举报
回复
procedure TfrmCBXX_KD.StringGrid1DrawCell(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState);

if (gdFocused in State) and (Trim(StringGrid1.Cells[acol,0])='抄表标志') then
begin
LI_I:=ACol; LI_J:=ARow;
combobox1.Text:=stringgrid1.Cells[ACol,ARow];
combobox1.Top:=Rect.Top+StringGrid1.top+3;
combobox1.Left:=Rect.Left+StringGrid1.Left+3;
combobox1.Height:=Rect.Bottom-Rect.Top;
combobox1.Width:=Rect.Right-Rect.Left;
combobox1.Visible:=true;
combobox1.Text:='';
LB_CBBZ:=false;
combobox1.Update;
combobox1.SetFocus;
end;

当然,用鼠标点击目标列,可以看到combobox控件,
但是不用鼠标点击,就用鍵盘上的光标键来选择小格子,当用向左光标键从右向左
调动时,调动到目标列时,就看不到这个combobox控件!

所以我才提出如何调用StringGrid控件的DrawCell事件!
分不够的话,可以再加 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
snowtiger2000 2003-01-08
  • 打赏
  • 举报
回复
在onclick事件中添加显示的代码

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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