前台:
procedure load_DBgrideh_col(sender: tobject; id: integer);
var s: string;
i: integer;
begin
dm.sq := 'select * from zsp_autocol where FunID=' + inttostr(id);
dm.Open_SQ;
if dm.Q1.Eof then
begin
dm.sq := ' insert into zsp_autocol (FunID,comment) values (' + inttostr(id) + ',' + #39 + '铁路' + #39 + ')';
dm.Exe_SQ;
end;
dm.sq := 'select * from zsp_autocol where FunID=' + inttostr(id);
dm.Open_SQ;
if sender is tdbgrid then
begin
for I := 0 to (sender as tdbgrid).Columns.Count - 1 do
begin
(sender as tdbgrid).Columns.Items.Width := dm.gfI('COL' + INTTOSTR(I));
(sender as tdbgrid).Columns.Items.Title.Alignment := taCenter;
end;
end;
if sender is tdbgrideh then
begin
for I := 0 to (sender as tdbgrideh).Columns.Count - 1 do
begin
(sender as tdbgrideh).Columns.Items.Width := dm.gfI('COL' + INTTOSTR(I));
(sender as tdbgrideh).Columns.Items.Title.Alignment := taCenter;
end;
end;
end;
procedure save_DBgrideh_col(sender: tobject; id: integer);
var s: string;
i: integer;
begin
if dm.bCanConfigCol then
begin
s := 'update ZSP_AUTOCOL set comment=comment';
if sender is tdbgrideh then for I := 0 to (sender as tDBGridEh).Columns.Count - 1 do s := s + ',COL' + INTTOSTR(I) + '=' + inttostr((sender as tDBGridEh).Columns.Items.Width);
if sender is tdbgrid then for I := 0 to (sender as tDBGrid).Columns.Count - 1 do s := s + ',COL' + INTTOSTR(I) + '=' + inttostr((sender as tDBGrid).Columns.Items.Width);
s := s + ' where funid=' + inttostr(id);
dm.ExecSQL(s);
end;
end;
--------------------------------
后台:
create procedure zsp_查询GRIDE_COL
(
@FUNID INT,
@COMMENT NVARCHAR(100)
)
AS
if not exists(select * from zsp_autocol where FunID=@funID)
insert into zsp_autocol (FunID,comment) values (@funid,@comment)
select * from zsp_autocol where FunID=@funID
GO
----------
兄弟:可以调节 dbgrid/dbgrideh!