设计想法如下: 一个动态生成的form,触发ShowPropBox过程,弹出此form。
unit uValue;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, ComCtrls, StdCtrls;type
TfrmItemProp = class(TForm)
Panel1: TPanel;
HeaderControl1: THeaderControl;
btnApply: TButton;
btnNew: TButton;
btnClose: TButton;
btnDelete: TButton;
private
{ Private declarations }
public
{ Public declarations }
end;var
frmItemProp: TfrmItemProp;procedure ShowPropBox;implementation{$R *.dfm}procedure ShowPropBox;
begin
with TfrmItemProp.Create(Application) do
try
ShowModal;
finally
Free;
end;
end;end.
HeaderControl1分为"property"(属性)和"value"(值)两个项。
在此form中主要显示"property"(属性)和"value"(值)两个项。每个property对应一个value。form有4个按钮"Apply","New","Delete","Close"。"New"按钮用来生成新的property和value,具体的property和value由用户自己输入。"Delete"按钮用来删除选定的property和value。"Apply"就是保存修改。"Close"关闭。第一次弹出时,property和value显示为空。
点击"New"按钮时,生成新的一行property和value,具体的property和value由用户自己输入。输入好后按"Apply"按钮保存或者按"Delete"按钮删除该行property和value。
下次打开该form的时候显示已保存的property和value,并且可以继续添加或删除。请教各位,程序该怎么写?
unit uValue;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, ComCtrls, StdCtrls;type
TfrmItemProp = class(TForm)
Panel1: TPanel;
HeaderControl1: THeaderControl;
btnApply: TButton;
btnNew: TButton;
btnClose: TButton;
btnDelete: TButton;
private
{ Private declarations }
public
{ Public declarations }
end;var
frmItemProp: TfrmItemProp;procedure ShowPropBox;implementation{$R *.dfm}procedure ShowPropBox;
begin
with TfrmItemProp.Create(Application) do
try
ShowModal;
finally
Free;
end;
end;end.
HeaderControl1分为"property"(属性)和"value"(值)两个项。
在此form中主要显示"property"(属性)和"value"(值)两个项。每个property对应一个value。form有4个按钮"Apply","New","Delete","Close"。"New"按钮用来生成新的property和value,具体的property和value由用户自己输入。"Delete"按钮用来删除选定的property和value。"Apply"就是保存修改。"Close"关闭。第一次弹出时,property和value显示为空。
点击"New"按钮时,生成新的一行property和value,具体的property和value由用户自己输入。输入好后按"Apply"按钮保存或者按"Delete"按钮删除该行property和value。
下次打开该form的时候显示已保存的property和value,并且可以继续添加或删除。请教各位,程序该怎么写?
然后使用sl.Values['property1'] := 'value1'来保存数据。
begin
if FrmItemProp = nil then TfrmItemProp.Create(Application);
try
ShowModal;
finally
Hide; //不Free他,因为以后还用得着!
end;
end;
uses IniFiles;
var
ini : TIniFile;
//新增
ini.WriteString
//删除
ini.DeleteKey
//装载
ini.ReadString
第一个窗体代码unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation
uses unit2 ;{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
with TForm2.create(self) do
begin
try
Form2Execute(); finally
free;
end;
end;
end;procedure TForm1.FormCreate(Sender: TObject);
beginend;end.第二个窗体代码
unit Unit2;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;type
TForm2 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
function Form2Execute(): boolean;
procedure ShowPropBox;
end;var
Form2: TForm2;implementation{$R *.dfm}function TForm2.Form2Execute(): boolean;
begin
ShowPropBox ;end;procedure TForm2.ShowPropBox;
begin ShowModal;end;procedure TForm2.FormCreate(Sender: TObject);
beginend;end.你试试一定能通过