我在窗体中放置了两个StringGrid,但是程序运行起来后,每个StringGrid的cell[1,1]都有蓝色阴影存在,看上去像有光标落在上面。我在窗体的onshow事件中,写了:
comboBox1.setfocus;
但是也没有改变这种效果。如何处理?

解决方案 »

  1.   

    comboBox1.setfocus;
    不懂是什么意思?
      

  2.   

    comboBox1,selected
    或者
    comboBox1.selection 里面的有个属性需要修改了
      

  3.   

    comboBox1.setfocus;
    只是为了让窗体上的combobox获得焦点,但是stringgrid仍然有阴影存在。
      

  4.   

    stringgrid显示时,它的canvas默认对第一格高亮,你需要将StringGrid的DefaultDrawing设为false,然后根据自己的意愿写OnDrawCell事件
      

  5.   

    我现在明白你的意思了~!
      你是想把焦点转移到combobox1,
      而让stringgri1的那个阴影消失是吧!
      

  6.   

    只能象 Sunny21() 说的
    将StringGrid的DefaultDrawing设为false,然后根据自己的意愿写OnDrawCell事件
      

  7.   

    仔细看一下以下代码就可以解决你的问题,OK!
    在StringGrid的DrawCell事件中写代码procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
    begin
      with Rect, StringGrid1.Canvas do
      begin
        if State = [gdSelected] then
        begin
          Brush.Color:=clWhite;
          FillRect(Rect);
          Font.Color:=clBlack;
        end;
      end;
    end;
      

  8.   

    to  Hank(星星农场) : 
    我试了一下,还是不行。阴影是没有了,但是每个StringGrid的cell[1,1]显示的是空白,点击其他cell才能将cell[1,1]数据显示出来。怎么解决呢?
      

  9.   

    我还以为剩下的你知道呢,然后用TextRect输出即可例如:  with Rect, StringGrid1.Canvas do
      begin
        if State = [gdSelected] then
        begin
          Brush.Color:=clWhite;
          FillRect(Rect);
          Font.Color:=clBlack;
        end;
        TextRect(Rect,Left+2,Top+2,StringGrid1.Cells[ACol,ARow]);
      end;