cx控件里面有两个控件,cxGridPopupMenu1 及cxPropertiesStore1. cxGridPopupMenu1 是自带右键,很好使用,只需要设置Grid属性为你的CXGRD就可 popupmenus属性里面可以增加普通PopupMenu1,只要popupmenus点开增加,增加后设置Gridview及popupmenu对你对应的控件,Hittypes表示你这个popupmenu在哪些位置可以右键出现.cxPropertiesStore1 控件也很方便,只需要把控件拖到Form上,然后双击这里面会显示Form里面所有的控件,选中需要保存风格的控件,右键就可(颜色会变蓝色).cxPropertiesStore1的active可以设置成true,storagetype有三种方式,INI,注册表,stream
INI最简单,StorageName可以是INI的名字,可以是全路径名.比方 c:\aaa.ini 只需要把active设置成TRUE.接下来就是两句代码 窗体加载的时候:cxPropertiesStore1.RestoreFrom; 关闭的时候:cxPropertiesStore1.StoreTo(true);
另外想初始成原始风格 只需要
var
  a: TStrings;
begin
  a := TStringList.Create;
  a.SaveToFile('c:\aaa.ini');
  a.Free;
  ShowMessage('重新登陆!');把INI文件清除 重新登陆.PS:如果选择的控件比较多可能关闭及启动会比较慢
下面是 用cxgrid的属性保存风格,这样能保存的就太少了 不过一般性的应用就够了
var
  ms: TMemoryStream;
  f: TIniFile;
begin
  ms := TMemoryStream.Create;
  try
   // f:=TIniFile.Create('C:\AA.INI');
    cxGrid1DBTableView1.StoreToStream(ms);
   // cxGrid1DBTableView1.StoreToIniFile('C:\AA.INI');
    ADOQuery1.SQL.Clear;
    ADOQuery1.SQL.Text := ('delete from TableSet where opid=1 and tablename=''First'' ');
    ADOQuery1.ExecSQL;
    ADOQuery1.SQL.Clear;
    ADOQuery1.SQL.Text := ('INSERT INTO TableSet (TableName,Opid,Set1 ) VALUES (:x,:y,:z) ');
    ADOQuery1.Parameters.ParamByName('x').Value := 'First';
    ADOQuery1.Parameters.ParamByName('y').Value := 1;
    ADOQuery1.Parameters.ParamByName('z').LoadFromStream(TStream(ms), ftMemo);
    ShowMessage(ADOQuery1.SQL.Text);
    ADOQuery1.ExecSQL;
  except
    ShowMessage('出错!');
  end;
end;
var
  Stream: TMemoryStream;
begin
  //cxGrid1DBTableView1.RestoreFromIniFile('C:\AA.INI'); // ADOQuery2.Close;
  Stream := TMemoryStream.Create;
  ADOQuery1.SQL.Clear;
  ADOQuery1.SQL.Text := ('SELECT * from TableSet where opid=1 and tablename=''First'' ');
  try
    try
      ADOQuery1.Open;
      stream := TMemoryStream(ADOQuery1.CreateBlobStream(ADOQuery1.FieldByName('Set1'), bmRead));
      cxGrid1DBTableView1.RestoreFromStream(Stream);
    except
      begin
        ShowMessage('Error!');
      end;
    end;
  finally
    stream.Free;
  end;
//  ADOQuery2.Open;
end;

解决方案 »

  1.   

    百度上搜索 cxPropertiesStore1 基本没有资料http://www.devexpress.com/ 这里有好多资料
      

  2.   

    补充一下,不需要控件,就能保存表格设置,
    cxgrid有TcxCustomGridView.StoreToRegistry,TcxCustomGridView.StoreToStream,TcxCustomGridView.StoreToIniFile等方法。语法
    procedure StoreToRegistry(const AStorageName: string; AReCreate: Boolean = True; AOptions: TcxGridStorageOptions = []; const ASaveViewName: string = '');
    Description
     
    Use the StoreToRegistry method to save view-specific information to the registry. This information can be restored after the changes have been applied to a view. Use the RestoreFromRegistry method to restore the view structure. Before restoring the view structure, ensure that the view is connected to a data set containing the same fields assigned to the view items as were saved in a registry key.
     
    View structure information includes: view class and instance names, bands, column or row settings (according to the view type). View element (bands, columns and card view rows) settings specify the position and visibility within a view, caption, sort order, data binding settings and etc.
     The registry path for the view information is formed by adding the AStorageName suffix to the HKEY_CURRENT_USER key.
     The AReCreate parameter determines whether the required key is recreated via each call of the StoreToRegistry method. If this parameter value is True, then the existing registry key is deleted and then created again. Otherwise, information is appended to the existing key.
     For information on the AOptions and ASaveViewName parameters, see the description of the RestoreFromIniFile method.
     To customize the list of the view's properties which are saved to the registry, use the OnGetStoredProperties and OnGetStoredPropertyValue events.
    请查找一下帮助,里面有介绍。