调整窗体中StringGrid控件的列的宽度,关闭该窗体,重新进入这个窗体使StringGrid的宽度恢复原状,咋做
解决方案 »
- 热键注册的问题,不响应热键!~
- 怎么样用DELPHI监控文本变化,直到我想要的内容出现然后触发事件?
- [紧急]跪求用友U8财务接口及方案,千分相赠
- 医学影像系统(BCB6.0+InterBase6.5)欲出售源代码,有意请进!!
- 怎样在TScrollBox中绘图?
- 怎样在edit中显示一个变量的内存地址,需要使用到什么样的API函数。谢谢!在线等候!
- 一个文件操作的问题?
- Trim函数说明从给定的字符串中删除前导和尾部的空格及控制字符,请问什么是控制字符?
- 急需InfoPower3000Pro序列号.
- 关于系统注册表的代码问题
- 不能载入gds32.dll
- 在树控件中选中节点一次后,再次点击鼠标如何判断是点在节点上还是树的空白区域上????
窗體上放了一個TStringGrid以及兩個TButton,其中Button1為恢復,Button2為將大小保存unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, StdCtrls;type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}uses
IniFiles;procedure TForm1.Button1Click(Sender: TObject);
var
IniFile: TIniFile;
I: Integer;
strTemp: string;
SL: TStringList;
begin
if FileExists(ExtractFilePath(Application.ExeName) + 'SGSetup.INI') then
begin
IniFile := TIniFile.Create(ExtractFilePath(application.ExeName) + 'SGSetup.INI');
SL := TStringList.Create;
try
strTemp := IniFile.ReadString('SGSETUP', 'RowSize', '');
if strTemp <> '' then
begin
SL.CommaText := strTemp;
for I := 0 to SL.Count - 1 do
StringGrid1.RowHeights[I] := StrToIntDef(SL[I], 10);
end; strTemp := IniFile.ReadString('SGSETUP', 'ColSize', '');
if strTemp <> '' then
begin
SL.CommaText := strTemp;
for I := 0 to SL.Count - 1 do
StringGrid1.ColWidths[I] := StrToIntDef(SL[I], 10);
end;
finally
SL.Free;
IniFile.Free;
end;
end;
end;procedure TForm1.Button2Click(Sender: TObject);
var
IniFile: TIniFile;
I: Integer;
SL: TStringList;
begin
IniFile := TIniFile.Create(ExtractFilePath(application.ExeName) + 'SGSetup.INI');
SL := TStringList.Create;
try
SL.CommaText := '';
for I := 0 to StringGrid1.RowCount - 1 do
SL.Add(IntToStr(StringGrid1.RowHeights[I]));
IniFile.WriteString('SGSETUP', 'RowSize',SL.CommaText); SL.CommaText := '';
for I := 0 to StringGrid1.ColCount - 1 do
SL.Add(IntToStr(StringGrid1.ColWidths[I]));
IniFile.WriteString('SGSETUP', 'ColSize',SL.CommaText); finally
SL.Free;
IniFile.Free;
end;
end;end.
不光列的宽度要还原, 我用的是第三方控件TAdvStringGrid (http://www.tmssoftware.com/)
可 按住“Shift”键 点 鼠标左键 后 多列复合排序 排序的列头会出现黄色的三角 ,
用Close关闭窗体后, 重新进入该窗体还会出现 。为什么会保留 ?