我是这样写的:
for i := 0 to ComponentCount - 1 do
begin
if (Components[i] is TcxGridDBTableView) and Sav then
TcxGridDBTableView(Components[i]).StoreToIniFile(ExtractFilePath(ParamStr(0)) + 'cxViewSet\' + Name + '_' + TcxGridDBTableView(Components[i]).DataController.DataSet.Name + '.ini')
else if (Components[i] is TcxGridDBTableView) and (not Sav) then
TcxGridDBTableView(Components[i]).RestoreFromIniFile(ExtractFilePath(ParamStr(0)) + 'cxViewSet\' + Name + '_' + TcxGridDBTableView(Components[i]).DataController.DataSet.Name + '.ini');
end;这只能保存和加载第一层cxGridDBTableView,子表记录如下:
[ChuKuForm.: TcxGridDBTableView]
=
Footer="False"
GroupByBox="True"
GroupFooters=0
NewItemRow="False"
Version=1[ChuKuForm./: TcxGridDBColumn]
=
GroupIndex=-1
Width=304
AlignmentHorz=0
Index=10
Visible="True"
SortOrder="soNone"
SortIndex=-1
WasVisibleBeforeGrouping="False"子表记录没有加载
for i := 0 to ComponentCount - 1 do
begin
if (Components[i] is TcxGridDBTableView) and Sav then
TcxGridDBTableView(Components[i]).StoreToIniFile(ExtractFilePath(ParamStr(0)) + 'cxViewSet\' + Name + '_' + TcxGridDBTableView(Components[i]).DataController.DataSet.Name + '.ini')
else if (Components[i] is TcxGridDBTableView) and (not Sav) then
TcxGridDBTableView(Components[i]).RestoreFromIniFile(ExtractFilePath(ParamStr(0)) + 'cxViewSet\' + Name + '_' + TcxGridDBTableView(Components[i]).DataController.DataSet.Name + '.ini');
end;这只能保存和加载第一层cxGridDBTableView,子表记录如下:
[ChuKuForm.: TcxGridDBTableView]
=
Footer="False"
GroupByBox="True"
GroupFooters=0
NewItemRow="False"
Version=1[ChuKuForm./: TcxGridDBColumn]
=
GroupIndex=-1
Width=304
AlignmentHorz=0
Index=10
Visible="True"
SortOrder="soNone"
SortIndex=-1
WasVisibleBeforeGrouping="False"子表记录没有加载
for i := 0 to ComponentCount - 1 do //先看下這裏有沒有子表??沒有具體操作過,應該是 CxGrid 的 ControlCount 中找
[ChuKuForm.: TcxGridDBTableView]
=
Footer="False"
GroupByBox="True"
GroupFooters=0
NewItemRow="False"
Version=1[ChuKuForm./: TcxGridDBColumn]
=
GroupIndex=-1
Width=304
AlignmentHorz=0
Index=10
Visible="True"
SortOrder="soNone"
SortIndex=-1
WasVisibleBeforeGrouping="False"
我将代码放在FormCreate下发现只有编译会创建ini文件,重新打开窗体不创建ini文件
在D7安装目录下的Projects里运行不创建ini文件,是因为我的系统是vista,在Projects
文件夹里创建文件需要管理员权限