Delphi对SGridFunction的一些使用

//StringGrid的鼠标移动事件

procedure TfrmCKSJHD.sg_JCSJMouseMove(Sender: TObject; Shift: TShiftState;

X, Y: Integer);

begin

with sg_JCSJ do

begin

//当鼠标在标题行且不在序号列时,鼠标指针变成手形

if (GetRowByCY(sg_JCSJ, Y) = 0) and (GetColByCX(sg_JCSJ, X) <> 0) then

begin

Cursor := crHandPoint;

end

//其他情况鼠标指针为默认

else Cursor := crDefault;

end;

end;

//----------------------------------------------------------------------------//

//设置StringGrid的显示格式

//----------------------------------------------------------------------------//

procedure TfrmCKSJHD.SetSGridJCSJShowFormat;

var

ColIndex: Integer;

begin

//设置标题行的边距

SetRowMinSpaceWidth(sg_JCSJ, 0, 1);

//添加序号

SetNumberFields(sg_JCSJ, 0, 1);

//序号列右对齐

SetColAlignRight(sg_JCSJ, 0, 1);

//金额列右对齐

for ColIndex := 3 to 8 do

begin

SetColAlignRight(sg_JCSJ, ColIndex, 1);

end;

//设置每列的宽度

SetAllColWidth(sg_JCSJ);

end;

//----------------------------------------------------------------------------//

//数据导出到Excel

//----------------------------------------------------------------------------//

procedure TfrmCKSJHD.sbJYJGDCClick(Sender: TObject);

begin

//导出基础数据

if pc_DATA.ActivePage = ts_JCSJ then

begin

SGridFunction.ExportToExcel(sg_JCSJ, '', '基础数据', 0, 0, 1, 1);

end

else begin

//导出外部数据

if pc_DATA.ActivePage = ts_WBSJ then

begin

SGridFunction.ExportToExcel(sg_WBSJ, '', '外部数据', 0, 0, 1, 1);

end

//导出校验结果

else begin

SGridFunction.ExportToExcel(sg_JYJG, '', '校验结果', 0, 0, 1, 1);

end;

end;

end;