小
小溪水
Unregistered / Unconfirmed
GUEST, unregistred user!
TCustomDBGridEh.RestoreColumnsLayoutIni(IniFileName: String;Section: String;
RestoreParams: TColumnEhRestoreParams);这里RestoreParams该怎么写入? ( 积分: 20 )<br />[red]想让dbgrideh表格的格式从前面用[/red]
[blue]DBGridEh1.SaveGridLayoutIni('D:/delphi_测试/报表测试/dayintz.ini','grgzhz',True);[/blue]
[red]保存的格式恢复回来,DBGridEh1 控件里有这样的过程:[/red]
[blue]procedure TCustomDBGridEh.RestoreColumnsLayoutIni(IniFileName: String;
Section: String;
RestoreParams: TColumnEhRestoreParams);
可是我该怎么写这个RestoreColumnsLayoutIni?
RestoreColumnsLayoutIni('D:/delphi_测试/报表测试/dayintz.ini','grgzhz',??);
后面的RestoreParams: TColumnEhRestoreParams 怎么写呢?试了好几个都不对 [/blue]
[black]-----------------------------------
部分控件源码:
TColumnEhRestoreParam = (crpColIndexEh, crpColWidthsEh, crpSortMarkerEh, crpColVisibleEh,
crpDropDownRowsEh, crpDropDownWidthEh);
TColumnEhRestoreParams = set of TColumnEhRestoreParam;
----------------------------------------------------------------
procedure TCustomDBGridEh.RestoreColumnsLayoutProducer(ARegIni: TObject;
Section: String;
RestoreParams: TColumnEhRestoreParams);
type
TColumnInfo = record
Column: TColumnEh;
EndIndex: Integer;
SortMarker: TSortMarkerEh;
SortIndex: Integer;
end;
PColumnArray = ^TColumnArray;
TColumnArray = array[0..0] of TColumnInfo;
const
Delims = [' ', ','];
var
I, J: Integer;
S: string;
ColumnArray: PColumnArray;
AAutoFitColWidth: Boolean;
begin
AAutoFitColWidth := False;
begin
Update;
try
if (AutoFitColWidths) then
begin
AutoFitColWidths := False;
AAutoFitColWidth := True;
end;
with Columnsdo
begin
ColumnArray := AllocMem(Count * SizeOf(TColumnInfo));
try
for I := 0 to Count - 1do
begin
if (ARegIni is TRegIniFile)
then
S := TRegIniFile(ARegIni).ReadString(Section, Format('%s.%s', [Name, Items.FieldName]), '')
else
S := TCustomIniFile(ARegIni).ReadString(Section, Format('%s.%s', [Name, Items.FieldName]), '');
ColumnArray^.Column := Items;
ColumnArray^.EndIndex := Items.Index;
if S <> '' then
begin
ColumnArray^.EndIndex := StrToIntDef(ExtractWord(1, S, Delims),
ColumnArray^.EndIndex);
if (crpColWidthsEh in RestoreParams) then
Items.Width := StrToIntDef(ExtractWord(2, S, Delims),
Items.Width);
if (crpSortMarkerEh in RestoreParams) then
Items.Title.SortMarker := TSortMarkerEh(StrToIntDef(ExtractWord(3, S, Delims),
Integer(Items.Title.SortMarker)));
if (crpColVisibleEh in RestoreParams) then
Items.Visible := Boolean(StrToIntDef(ExtractWord(4, S, Delims), Integer(Items.Visible)));
if (crpSortMarkerEh in RestoreParams) then
ColumnArray^.SortIndex := StrToIntDef(ExtractWord(5, S, Delims), 0);
if (crpDropDownRowsEh in RestoreParams) then
Items.DropDownRows := StrToIntDef(ExtractWord(6, S, Delims), Items.DropDownRows);
if (crpDropDownWidthEh in RestoreParams) then
Items.DropDownWidth := StrToIntDef(ExtractWord(7, S, Delims), Items.DropDownWidth);
end;
end;
if (crpSortMarkerEh in RestoreParams) then
for I := 0 to Count - 1do
Items.Title.SortIndex := ColumnArray^.SortIndex;
if (crpColIndexEh in RestoreParams) then
for I := 0 to Count - 1do
for J := 0 to Count - 1do
if ColumnArray^[J].EndIndex = I then
begin
ColumnArray^[J].Column.Index := ColumnArray^[J].EndIndex;
Break;
end;
finally
FreeMem(Pointer(ColumnArray));
end;
end;
finally
EndUpdate;
if (AAutoFitColWidth = True)
then
AutoFitColWidths := True
else
LayoutChanged;
end;
end;
------------------------------------------------------------------
[/black]
RestoreParams: TColumnEhRestoreParams);这里RestoreParams该怎么写入? ( 积分: 20 )<br />[red]想让dbgrideh表格的格式从前面用[/red]
[blue]DBGridEh1.SaveGridLayoutIni('D:/delphi_测试/报表测试/dayintz.ini','grgzhz',True);[/blue]
[red]保存的格式恢复回来,DBGridEh1 控件里有这样的过程:[/red]
[blue]procedure TCustomDBGridEh.RestoreColumnsLayoutIni(IniFileName: String;
Section: String;
RestoreParams: TColumnEhRestoreParams);
可是我该怎么写这个RestoreColumnsLayoutIni?
RestoreColumnsLayoutIni('D:/delphi_测试/报表测试/dayintz.ini','grgzhz',??);
后面的RestoreParams: TColumnEhRestoreParams 怎么写呢?试了好几个都不对 [/blue]
[black]-----------------------------------
部分控件源码:
TColumnEhRestoreParam = (crpColIndexEh, crpColWidthsEh, crpSortMarkerEh, crpColVisibleEh,
crpDropDownRowsEh, crpDropDownWidthEh);
TColumnEhRestoreParams = set of TColumnEhRestoreParam;
----------------------------------------------------------------
procedure TCustomDBGridEh.RestoreColumnsLayoutProducer(ARegIni: TObject;
Section: String;
RestoreParams: TColumnEhRestoreParams);
type
TColumnInfo = record
Column: TColumnEh;
EndIndex: Integer;
SortMarker: TSortMarkerEh;
SortIndex: Integer;
end;
PColumnArray = ^TColumnArray;
TColumnArray = array[0..0] of TColumnInfo;
const
Delims = [' ', ','];
var
I, J: Integer;
S: string;
ColumnArray: PColumnArray;
AAutoFitColWidth: Boolean;
begin
AAutoFitColWidth := False;
begin
Update;
try
if (AutoFitColWidths) then
begin
AutoFitColWidths := False;
AAutoFitColWidth := True;
end;
with Columnsdo
begin
ColumnArray := AllocMem(Count * SizeOf(TColumnInfo));
try
for I := 0 to Count - 1do
begin
if (ARegIni is TRegIniFile)
then
S := TRegIniFile(ARegIni).ReadString(Section, Format('%s.%s', [Name, Items.FieldName]), '')
else
S := TCustomIniFile(ARegIni).ReadString(Section, Format('%s.%s', [Name, Items.FieldName]), '');
ColumnArray^.Column := Items;
ColumnArray^.EndIndex := Items.Index;
if S <> '' then
begin
ColumnArray^.EndIndex := StrToIntDef(ExtractWord(1, S, Delims),
ColumnArray^.EndIndex);
if (crpColWidthsEh in RestoreParams) then
Items.Width := StrToIntDef(ExtractWord(2, S, Delims),
Items.Width);
if (crpSortMarkerEh in RestoreParams) then
Items.Title.SortMarker := TSortMarkerEh(StrToIntDef(ExtractWord(3, S, Delims),
Integer(Items.Title.SortMarker)));
if (crpColVisibleEh in RestoreParams) then
Items.Visible := Boolean(StrToIntDef(ExtractWord(4, S, Delims), Integer(Items.Visible)));
if (crpSortMarkerEh in RestoreParams) then
ColumnArray^.SortIndex := StrToIntDef(ExtractWord(5, S, Delims), 0);
if (crpDropDownRowsEh in RestoreParams) then
Items.DropDownRows := StrToIntDef(ExtractWord(6, S, Delims), Items.DropDownRows);
if (crpDropDownWidthEh in RestoreParams) then
Items.DropDownWidth := StrToIntDef(ExtractWord(7, S, Delims), Items.DropDownWidth);
end;
end;
if (crpSortMarkerEh in RestoreParams) then
for I := 0 to Count - 1do
Items.Title.SortIndex := ColumnArray^.SortIndex;
if (crpColIndexEh in RestoreParams) then
for I := 0 to Count - 1do
for J := 0 to Count - 1do
if ColumnArray^[J].EndIndex = I then
begin
ColumnArray^[J].Column.Index := ColumnArray^[J].EndIndex;
Break;
end;
finally
FreeMem(Pointer(ColumnArray));
end;
end;
finally
EndUpdate;
if (AAutoFitColWidth = True)
then
AutoFitColWidths := True
else
LayoutChanged;
end;
end;
------------------------------------------------------------------
[/black]