Self.tvResult.Items[i].ApplyBestFit; //调整为最佳宽度 Self.tvResult.EndUpdate; end;
//保存布局
IniFileName := ExtractFilePath(Application.ExeName) + 'Layout/' + Self.Name + '.ini'; if not DirectoryExists(ExtractFileDir(IniFileName)) then CreateDir(ExtractFileDir(IniFileName));
Self.tvResult.StoreToIniFile(IniFileName); //保存为布局文件 实例:
IniFileName: string;
procedure TMainFM.FormCreate(Sender: TObject); //窗体创建时读取布局 var i: Integer; begin
qyHed.Open;
IniFileName := ExtractFilePath(Application.ExeName) + '/Layout/' + cxGrd.Owner.ClassName + cxGrd.Name + '.ini'; if FileExists(IniFileName) then
Self.cxTbv.RestoreFromIniFile(IniFileName) //从布局文件中恢复 else begin
Self.cxTbv.BeginUpdate;
for i := 0 to Self.cxTbv.ItemCount - 1 do
Self.cxTbv.Items[i].ApplyBestFit; //调整为最佳宽度 Self.cxTbv.EndUpdate; end; end;
procedure TMainFM.NSaveGrdClick(Sender: TObject); //保存布局文件 begin try
IniFileName := ExtractFilePath(Application.ExeName) + '/Layout/' + cxGrd.Owner.ClassName + cxGrd.Name + '.ini'; if not DirectoryExists(ExtractFileDir(IniFileName)) then CreateDir(ExtractFileDir(IniFileName)); Self.cxTbv.StoreToIniFile(IniFileName); except end; end;
**************************************************************************** 28保存/恢复带汇总行的布局解决:
.StoreToIniFile('c:/Grid.ini', True, [gsoUseSummary]);
****************************************************************************
(以下原博主转载自http://hi.http://www.wodefanwen.com//jangill/blog/item/2cf3c782f82f0798f703a67f.html) **************************************************************************** 28 在主从TableView中根据主TableView得到对应的从TableView 解决: var
ADetailDC: TcxGridDataController; AView: TcxCustomGridTableView; begin
with cxGrid1DBTableView1.DataController do
ADetailDC := TcxGridDataController(GetDetailDataController(FocusedRecordIndex, 0)); AView := ADetailDC.GridView; end;
============================================================================== 29 定位在第一行并显示内置编辑器
cxDBVerticalGrid1.FocusedRow := cxDBVerticalGrid1.Rows[0]; cxDBVerticalGrid1.ShowEdit;
============================================================================== 30 隐藏 \字符串
该文本存储在scxGridNoDataInfoText资源字符串,可以将该资源字符串的内容设为空 来隐藏该文本。
uses cxClasses, cxGridStrs; ...
cxSetResourceString(@scxGridNoDataInfoText, ''); //如果\字符串已经显示,需要调用:
============================================================ 31 删除应用过滤后的行 var I: Integer; begin
with
for I := 0 to ViewData.RecordCount - 1 do begin
ViewData.Records[0].Focused := True; DataController.DataSet.Delete; end;
=============================================================
32 根据单元的值设置样式 解决:
procedure .StylesGetContentStyle(
Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; out AStyle: TcxStyle); begin
if ARecord.Values[AItem.Index] = aSomeValue then AStyle := ; end;
procedure .StylesGetContentStyle(
Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; out AStyle: TcxStyle); var
AColumn: TcxCustomGridTableItem; begin
AColumn := (Sender as TcxGridDBTableView).GetColumnByFieldName('Email'); if VarToStr(ARecord.Values[AColumn.Index]) = '' then AStyle := cxStyleNullEmail; end;
======================================================================
TcxCustomGridTableView.FindItemByName, TcxGridDBTableView.GetColumnByFieldName or TcxGridDBDataController.GetItemByFieldName
with cxGrid1DBBandedTableView1.DataController do
AValue := Values[FocusedRecordIndex, GetItemByFieldName('SomeFieldName').Index];
**************************************************************************** 33 动态生成BandedView 解决: var
AView: TcxCustomGridView; begin
AView :=
TcxGridDBBandedTableView(AView).DataController.DataSource :=
with TcxGridDBBandedTableView(AView).Bands.Add do begin
Visible := False; FixedKind := fkLeft; end;
TcxGridDBBandedTableView(AView).DataController.CreateAllItems;
**************************************************************************** 34 当底层数据集为空时显示一条空记录 解决:
procedure
相关推荐: