是这样的:
  在StringGrid控件中嵌入一个combobox控件!当A列被选中后,combobx控件才显示出来!当用鍵盘上的向左光标键调节到A列时,combobox控件没显示出来?
我不知道为什么?

解决方案 »

  1.   

    在onclick事件中添加显示的代码
      

  2.   

    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事件!
    分不够的话,可以再加 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      

  3.   

    procedure TForm1.StringGrid1Enter(Sender: TObject);
    begin
      //here your code is ok;
    end;
      

  4.   

    如果实在不行,你可以定义一个消息:const
      DrawCell = WM_USER + 1;procedure STRINGGRID(var Msg: TMessage); message FHLM_STRINGGRID;
    ...procedure STRINGGRID.DrawCell(var Msg: TMessage);
    begin
      DrawCell;
    end;
      

  5.   

    错了,重来:
    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;
      

  6.   

    在selectcell事件里判断
    并用stringgrid1.Selection.属性固定位置。
      

  7.   

    在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;