J
jemsn2
Unregistered / Unconfirmed
GUEST, unregistred user!
各位朋友,代码如下,当DBGRIDEH独立放置在窗体,而不是放进PageControl里面的时候,下面的代码就可以正常写出配置文件,但当PageControl包含了DBGRIDEH的时候,配置文件就不能将DBGRIDEH的属性写出来了,请问该怎样改,才可以使DBGRIDEH即使在PageControl里面,也可以将它的各种属性写出来呢,请各位朋友赐教,多谢!!!
procedure TFrm_Load_Save_Control.Save_Load_Control(sform: TForm; Read_Write: string);
var
i, j: Integer;
begin
for i := 0 to sform.ControlCount - 1 do
begin
if sForm.Controls.ClassType = TDBGridEh then //Tdbgrideh
begin
(sform.Controls as TDBGridEh).Font.Charset := DEFAULT_CHARSET; //设置默认语言
(sform.Controls as TDBGridEh).Font.Name := 'MS Sans Serif'; //设置默认语言的字体
for j := 0 to (sform.Controls as Tdbgrideh).Columns.Count - 1 do
begin
if (sform.Controls as Tdbgrideh).Columns[j].Visible then //只要可见的列,不可见的列不需要
begin
if Read_Write = 'write' then
Write_Ini(sform.Name, 'TDBGridEh', sform.Controls.Name + IntToStr(j), (sform.Controls as TDBGridEh).Columns[j].title.caption); ;
if Read_Write = 'read' then
(sform.Controls as TDBGridEh).Columns[j].title.caption := Read_Ini(sform.Name, 'TDBGridEh', sform.Controls.Name + IntToStr(j));
end;
end;
end;
if sform.Controls.ClassType = TPageControl then
begin
(sform.Controls as TPageControl).Font.Charset := DEFAULT_CHARSET; //设置默认语言
(sform.Controls as TPageControl).Font.Name := 'MS Sans Serif'; //设置默认语言的字体
for j := 0 to (sform.Controls as TPageControl).PageCount - 1 do
begin
if Read_Write = 'write' then
Write_Ini(sform.Name, 'TPageControl', sform.Controls.Name + IntToStr(j), (sform.Controls as TPageControl).Pages[j].Name);
if Read_Write = 'read' then
(sform.Controls as TPageControl).Pages[j].Name := Read_Ini(sform.Name, 'TPageControl', sform.Controls.Name + IntToStr(j));
end;
end;
END;
配置文件只显示了以下的结果,而不能达到如期的效果,将DBGRIDEH的属性也一起写进配置文件
[TPageControl]
PageControl10=TabSheet1
PageControl11=TabSheet2
procedure TFrm_Load_Save_Control.Save_Load_Control(sform: TForm; Read_Write: string);
var
i, j: Integer;
begin
for i := 0 to sform.ControlCount - 1 do
begin
if sForm.Controls.ClassType = TDBGridEh then //Tdbgrideh
begin
(sform.Controls as TDBGridEh).Font.Charset := DEFAULT_CHARSET; //设置默认语言
(sform.Controls as TDBGridEh).Font.Name := 'MS Sans Serif'; //设置默认语言的字体
for j := 0 to (sform.Controls as Tdbgrideh).Columns.Count - 1 do
begin
if (sform.Controls as Tdbgrideh).Columns[j].Visible then //只要可见的列,不可见的列不需要
begin
if Read_Write = 'write' then
Write_Ini(sform.Name, 'TDBGridEh', sform.Controls.Name + IntToStr(j), (sform.Controls as TDBGridEh).Columns[j].title.caption); ;
if Read_Write = 'read' then
(sform.Controls as TDBGridEh).Columns[j].title.caption := Read_Ini(sform.Name, 'TDBGridEh', sform.Controls.Name + IntToStr(j));
end;
end;
end;
if sform.Controls.ClassType = TPageControl then
begin
(sform.Controls as TPageControl).Font.Charset := DEFAULT_CHARSET; //设置默认语言
(sform.Controls as TPageControl).Font.Name := 'MS Sans Serif'; //设置默认语言的字体
for j := 0 to (sform.Controls as TPageControl).PageCount - 1 do
begin
if Read_Write = 'write' then
Write_Ini(sform.Name, 'TPageControl', sform.Controls.Name + IntToStr(j), (sform.Controls as TPageControl).Pages[j].Name);
if Read_Write = 'read' then
(sform.Controls as TPageControl).Pages[j].Name := Read_Ini(sform.Name, 'TPageControl', sform.Controls.Name + IntToStr(j));
end;
end;
END;
配置文件只显示了以下的结果,而不能达到如期的效果,将DBGRIDEH的属性也一起写进配置文件
[TPageControl]
PageControl10=TabSheet1
PageControl11=TabSheet2