设计想法如下: 一个动态生成的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,并且可以继续添加或删除。请教各位,程序该怎么写?

解决方案 »

  1.   

    好大的问题啊。我只回答关于保存。最简单的方法是你创建一个StringList(假定名字为sl)。
    然后使用sl.Values['property1'] := 'value1'来保存数据。
      

  2.   

    procedure ShowPropBox;
    begin
      if FrmItemProp = nil then TfrmItemProp.Create(Application);
      try
        ShowModal;
      finally
        Hide;  //不Free他,因为以后还用得着!
      end;
    end;
      

  3.   

    借助于ini文件来实现楼主所说的功能,下面我说一下思路
    uses IniFiles;
    var
      ini : TIniFile;
    //新增
      ini.WriteString
    //删除
      ini.DeleteKey
    //装载
      ini.ReadString
      

  4.   

    谢谢楼上的各位,我主要是被卡在如何实现“new"按钮事件和“delete”按钮事件上了,不知道该如何实现。小弟刚学DELPHI不久,希望各位大大不吝赐教,小弟感激不尽!!
      

  5.   

    对于新建:先弹出一个窗口让用户输入Key的值。然后把这个Key值添加到ValueList中就OK了。至于Value值让用户自己稍后填写。对于删除:先取得用户当前选中的行,然后令ValueList删掉这一行就行了。
      

  6.   

    分都给我吧
    第一个窗体代码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.你试试一定能通过