用鼠标调整dbgrid列的位置后,保存,下次打开程序能够显示保存后的排列顺序
解决方案 »
- DBGrid 选中行变色 当DBGrid失去焦点或者刷新数据集后恢复原色(意思是:第一行不要变色,要不操作者以为第一行被选中)
- 想设计这样一种三层分布式系统,不知是否可行?
- 这个问题怎么解决?马上揭贴!!~~谢谢,
- 用terminate关闭TThread对象时和操作系统的版本有关系吗?
- 你知道吗?真诚求教
- 是不是问题?
- 用ADOquery來更新后台數據庫的問題
- 怎么设置TreeView的结点的编辑状态。
- 我真让它给k了-------
- 怎么建立能有Execute的对话框?
- 急寻mp3转 wav算法。
- http://192.168.1.147/web/server.dll为什么不能浏览服务,而是下载了呀?
但是dbgrid没有字段名的信息,只有title,而title的caption属性是可以重复的
打开时从INI文件中读取
with DBGEh do
begin
for i:=0 to Columns.Count-1 do
if Columns[i].Field<>nil then
with Columns[i] do
begin
tmp:=tmp+FieldName+',';
Params.Values[Fieldname+csLabel]:=Title.Caption;
Params.Values[FieldName+csIndex]:=IntToStr(i);
Params.Values[FieldName+csAlign]:=csAlignValues[Alignment];
if Visible then
Params.Values[FieldName+csVisible]:='1'
else
Params.Values[FieldName+csVisible]:='';
Params.Values[FieldName+csWidth]:=IntToStr(Width{Width_ColumnEhToField(DBGEh,Width)});
Params.Values[FieldName+csFT_Value]:=Footer.Value;
Params.Values[FieldName+csFT_ValueType]:=csFT_ValueTypes[Footer.ValueType];
Params.Values[FieldName+csMinWidth]:=IntToStr(MinWidth);
Params.Values[FieldName+csMaxWidth]:=IntToStr(MaxWidth); Params.Values[FieldName+csEh_Title+csFont_Name]:=Title.Font.Name;
Params.Values[FieldName+csEh_Title+csFont_Size]:=IntToStr(Title.Font.Size);
Params.Values[FieldName+csEh_Title+csFont_Color]:=IntToStr(Title.Font.Color);
Params.Values[FieldName+csEh_Title+csFont_Style]:=GetFontStyle(Title.Font); Params.Values[FieldName+csEh_Data+csFont_Name]:=Font.Name;
Params.Values[FieldName+csEh_Data+csFont_Size]:=IntToStr(Font.Size);
Params.Values[FieldName+csEh_Data+csFont_Color]:=IntToStr(Font.Color);
Params.Values[FieldName+csEh_Data+csFont_Style]:=GetFontStyle(Font); Params.Values[FieldName+csEh_Footer+csFont_Name]:=Footer.Font.Name;
Params.Values[FieldName+csEh_Footer+csFont_Size]:=IntToStr(Footer.Font.Size);
Params.Values[FieldName+csEh_Footer+csFont_Color]:=IntToStr(Footer.Font.Color);
Params.Values[FieldName+csEh_Footer+csFont_Style]:=GetFontStyle(Footer.Font); Params.Values[FieldName+csEh_Title+csFont_BColor]:=IntToStr(Title.Color);
Params.Values[FieldName+csEh_Data+csFont_BColor]:=IntToStr(Color);
Params.Values[FieldName+csEh_Footer+csFont_BColor]:=IntToStr(Footer.Color);
end;
Params.Values[csFields]:=tmp;
try
CommaText:=Params.Values[csFields];
for i:=0 to Count-1 do
begin
tmpName:=Strings[i];
if tmpName='' then Continue;
tmp1:=DBGEh.Columns.Add;
tmp2:=nil; //保持装载列原有的属性不变
for n:=0 to DBGEh.Columns.Count-1 do
if (DBGEh.Columns[n]<>tmp1) and
(DBGEh.Columns[n].FieldName=tmpName) then
begin
tmp2:=DBGEh.Columns[n];
Break;
end;
if tmp2<>nil then
tmp1.Assign(tmp2);
with tmp1 do //仅改变保存的属性
begin
FieldName:=tmpName;
if Params.Values[FieldName+csVisible]='1' then
Visible:=True
else
Visible:=False;
Width:=StrToIntDef(Params.Values[FieldName+csWidth], 10);//Width_FieldToColumnEh(DBGEh, StrToIntDef(Params.Values[FieldName+csWidth], 10));
Title.Caption:=Params.Values[FieldName+csLabel];
if Field<>nil then
Field.DisplayLabel:=Title.Caption;