文档详情

cxGrid技巧汇总(一些常用代码).doc

发布:2017-12-12约1.55万字共21页下载文档
文本预览下载声明
cxGrid技巧汇总 ============================================================= 在主从TableView中根据主TableView得到对应的从TableView var ADetailDC: TcxGridDataController; AView: TcxCustomGridTableView; begin with cxGrid1DBTableView1.DataController do ADetailDC := TcxGridDataController(GetDetailDataController(FocusedRecordIndex, 0)); AView := ADetailDC.GridView; end; ============================================================= 定位在第一行并显示内置编辑器 cxDBVerticalGrid1.FocusedRow := cxDBVerticalGrid1.Rows[0]; cxDBVerticalGrid1.ShowEdit; ============================================================= 隐藏 No data to display 字符串 该文本存储在scxGridNoDataInfoText资源字符串,可以将该资源字符串的内容设为空 来隐藏该文本。 uses cxClasses, cxGridStrs;... cxSetResourceString(@scxGridNoDataInfoText, ); //如果No data to display 字符串已经显示,需要调用: View.LayoutChanged; ============================================================ 删除应用过滤后的行 var I: Integer; begin with GridView do for I := 0 to ViewData.RecordCount - 1 do begin ViewData.Records[0].Focused := True; DataController.DataSet.Delete; end; ============================================================= 根据单元的值设置样式 procedure aForm.aColumnStylesGetContentStyle( Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; out AStyle: TcxStyle); begin if ARecord.Values[AItem.Index] = aSomeValue then AStyle := aSomeStyle; end; procedure aForm.aViewStylesGetContentStyle( 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(SomeFiel
显示全部
相似文档