比如
StringGrid1 有 10 行 每行高度是 5 我想得到 
第一行 距离 StringGrid1高度是 0
第二行 距离 StringGrid1高度是 5
第三行 距离 StringGrid1高度是 10
第四行 距离 StringGrid1高度是 15当然可以通过计算得到 我是用stringgrid1.MouseCoord(X, Y); 函数返回当期行的行号 在 乘以 每行的高度 ,但这有个问题就是如果没有滚动条的情况下是可以的 ,但有滚动条就不对了 ,因为stringgrid1.MouseCoord(X, Y);返回的是行号.
我现在就想如何得到或计算出 每行对应 StringGrid控件的高度 呢? 或能得到 滚动条 的高度也可以,但怎么能得到呢?

解决方案 »

  1.   

    哦对了 MouseCoord(X, Y); 是我打错了  我用的是 form1.StringGrid1.Selection.top
    我主要想实现通过鼠标拖拽实现移动行数据的功能,因为需要一个计算 行数在 stringgrid 的top 来变化鼠标图标
    procedure TForm1.StringGrid1MouseDown(Sender: TObject;
      Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    begin
      if Button = mbleft then
      begin
        if (x > 0) and (x < StringGrid1.ColWidths[0]) and (y > (StringGrid1.DefaultRowHeight + 1) * StringGrid1.Selection.Top) and (y < (StringGrid1.DefaultRowHeight + 1) * (StringGrid1.Selection.Bottom + 1)) then
        begin
          Screen.Cursor := crdrag;
        end;
      end;
    end;