cxdxgridconverter.pas
来自「胜天进销存源码,国产优秀的进销存」· PAS 代码 · 共 1,743 行 · 第 1/5 页
PAS
1,743 行
ImportPropertiesCheckBox(AdxColumn, AcxColumn)
else if AdxColumn.ClassName = 'TdxDBGridImageColumn' then
ImportPropertiesImageComboBox(AdxColumn, AcxColumn)
else if AdxColumn.ClassName = 'TdxDBGridSpinColumn' then
ImportPropertiesSpinEdit(AdxColumn, AcxColumn)
else if AdxColumn.ClassName = 'TdxDBGridLookupColumn' then
ImportPropertiesLookupComboBox(AdxColumn, AcxColumn)
else if AdxColumn.ClassName = 'TdxDBGridPickColumn' then
ImportPropertiesComboBox(AdxColumn, AcxColumn)
else if AdxColumn.ClassName = 'TdxDBGridCalcColumn' then
ImportPropertiesCalcEdit(AdxColumn, AcxColumn)
else if AdxColumn.ClassName = 'TdxDBGridBlobColumn' then
ImportPropertiesBlobEdit(AdxColumn, AcxColumn)
else if AdxColumn.ClassName = 'TdxDBGridHyperLinkColumn' then
ImportPropertiesHyperLinkEdit(AdxColumn, AcxColumn)
else if AdxColumn.ClassName = 'TdxDBGridTimeColumn' then
ImportPropertiesTimeEdit(AdxColumn, AcxColumn)
else if AdxColumn.ClassName = 'TdxDBGridCurrencyColumn' then
ImportPropertiesCurencyEdit(AdxColumn, AcxColumn)
else if AdxColumn.ClassName = 'TdxDBGridMemoColumn' then
ImportPropertiesMemo(AdxColumn, AcxColumn)
else if AdxColumn.ClassName = 'TdxDBGridGraphicColumn' then
ImportPropertiesImage(AdxColumn, AcxColumn)
else if AdxColumn.ClassName = 'TdxDBGridMRUColumn' then
ImportPropertiesMRUEdit(AdxColumn, AcxColumn)
else if AdxColumn.ClassName = 'TdxDBGridPopupColumn' then
ImportPropertiesPopupEdit(AdxColumn, AcxColumn)
else if AdxColumn.ClassName = 'TdxDBGridExtLookupColumn' then
ImportPropertiesExLookupComboBox(AdxColumn, AcxColumn);
end;
procedure TcxRealConverterToTableView.ImportColumns;
var
AColumns: TList;
I: Integer;
begin
AColumns := TList.Create;
try
GetColumns(AColumns);
for I := 0 to AColumns.Count - 1 do
AssignColumn(CreateColumn, AColumns[I], I);
finally
AColumns.Free;
end;
end;
procedure TcxRealConverterToTableView.ImportColumnsStyles;
var
AColumns: TList;
AColumn: TcxGridDBColumn;
I: Integer;
AColor: Integer;
AFont: TFont;
AStyle: TcxCustomStyle;
begin
AColumns := TList.Create;
try
GetColumns(AColumns);
for I := 0 to AColumns.Count - 1 do
begin
AColumn := GetCXColumnByFieldName(Converter.GetStringProperty(AColumns[I], 'FieldName', ''));
AColor := Converter.GetIntegerProperty(TComponent(AColumns[I]), 'Color');
AFont := Converter.GetClassProperty(TComponent(AColumns[I]), 'Font') as TFont;
if ((AColor <> clWindow) and (AColor <> FColor)) or
(not DefaultFont(AFont) and not CompareFonts(AFont, FFont)) then
begin
AStyle := Converter.CreateStyleItem;
(AStyle as TcxStyle).Color := AColor;
(AStyle as TcxStyle).Font.Assign(AFont);
(AStyle as TcxStyle).TextColor := (AStyle as TcxStyle).Font.Color;
AColumn.Styles.Content := AStyle as TcxStyle;
end;
end;
finally
AColumns.Free;
end;
end;
procedure TcxRealConverterToTableView.ImportColumnSummaryGroups;
var
AColumns: TList;
AColumn: TcxGridDBColumn;
ASummaryField: string;
ASummaryFormat: string;
ASummaryGroupName: string;
ASummaryType: string;
ASummaryGroup: TcxDataSummaryGroup;
ASummaryItem: TcxGridDBTableSummaryItem;
ALink: TcxGridTableSummaryGroupItemLink;
AIndex: Integer;
I: Integer;
begin
AColumns := TList.Create;
try
GetColumns(AColumns);
for I := 0 to AColumns.Count - 1 do
begin
AColumn := GetCXColumnByFieldName(Converter.GetStringProperty(AColumns[I], 'FieldName', ''));
if AColumn = nil then
Continue;
ASummaryField := Converter.GetStringProperty(TComponent(AColumns[I]), 'SummaryField', '');
ASummaryFormat := Converter.GetStringProperty(TComponent(AColumns[I]), 'SummaryFormat', '');
ASummaryType := Converter.GetEnumProperty(TComponent(AColumns[I]), 'SummaryType');
ASummaryGroupName := Converter.GetStringProperty(TComponent(AColumns[I]), 'SummaryGroupName', '');
if ASummaryGroupName <> '' then
begin
if FcxSummaryGroups.Find(ASummaryGroupName, AIndex) then
begin
ASummaryGroup := TcxDataSummaryGroup(FcxSummaryGroups.Objects[AIndex]);
ALink := TcxGridTableSummaryGroupItemLink(ASummaryGroup.Links.Add);
ALink.Column := AColumn;
end;
end;
if (ASummaryField <> '') and (ASummaryType <> 'cstNone') then
begin
ASummaryGroup := cxGridView.DataController.Summary.SummaryGroups.Add;
ASummaryItem := TcxGridDBTableSummaryItem(ASummaryGroup.SummaryItems.Add);
ASummaryItem.FieldName := ASummaryField;
ASummaryItem.Format := ASummaryFormat;
ASummaryItem.Kind := GetSummaryKind(ASummaryType);
ALink := TcxGridTableSummaryGroupItemLink(ASummaryGroup.Links.Add);
ALink.Column := AColumn;
end;
end;
finally
AColumns.Free;
end;
end;
procedure TcxRealConverterToTableView.ImportDXFilter;
var
AFilter: TObject;
AStatus: string;
AFilterOptions: TcxFilterCriteriaOptions;
begin
AFilter := Converter.GetClassProperty(nil, 'Filter');
if AFilter <> nil then
begin
cxGridView.Filtering.DropDownWidth :=
Converter.GetIntegerProperty(AFilter, 'DropDownWidth', cxGridView.Filtering.DropDownWidth);
cxGridView.DataController.Filter.MaxValueListCount :=
Converter.GetIntegerProperty(AFilter, 'MaxDropDownCount', cxGridView.DataController.Filter.MaxValueListCount);
cxGridView.Filtering.MaxDropDownCount := Converter.GetIntegerProperty(AFilter, 'DropDownCount',
cxGridView.Filtering.MaxDropDownCount);
AStatus := Converter.GetEnumProperty(AFilter, 'FilterStatus');
if AStatus = 'fsAlways' then
cxGridView.Filtering.Visible := fvAlways
else if AStatus = 'fsAuto' then
cxGridView.Filtering.Visible := fvNonEmpty
else if AStatus = 'fsNone' then
cxGridView.Filtering.Visible := fvNever;
cxGridView.DataController.Filter.Active := Converter.GetBooleanProperty(AFilter, 'Active', cxGridView.DataController.Filter.Active);
ImportAutoDatasetFilter(Converter.GetBooleanProperty(AFilter, 'AutoDataSetFilter', False));
AFilterOptions := cxGridView.DataController.Filter.Options;
if Converter.GetBooleanProperty(AFilter, 'CaseInsensitive', False) then
Include(AFilterOptions, fcoCaseInsensitive);
cxGridView.DataController.Filter.Options := AFilterOptions;
end;
end;
procedure TcxRealConverterToTableView.ImportDXOptionsBehavior;
var
AList: TStringList;
I: Integer;
AOptions: TcxDataControllerOptions;
begin
AList := TStringList.Create;
try
Converter.EnablePropertyException;
try
Converter.GetSetProperty(nil, 'OptionsBehavior', AList);
AList.Sort;
with cxGridView do
begin
OptionsData.Editing := AList.Find('edgoEditing', I);
OptionsBehavior.ImmediateEditor := AList.Find('edgoImmediateEditor', I);
OptionsSelection.MultiSelect := AList.Find('edgoMultiSelect', I);
OptionsBehavior.GoToNextCellOnEnter := AList.Find('edgoEnterThrough', I);
OptionsBehavior.FocusCellOnTab := AList.Find('edgoTabs', I);
OptionsBehavior.FocusCellOnCycle := not Alist.Find('edgoTabThrough', I);
AOptions := DataController.Options;
if AList.Find('edgoAnsiSort', I) then
Include(AOptions, dcoAnsiSort);
if AList.Find('edgoCaseInsensitive', I) then
Include(AOptions, dcoCaseInsensitive);
DataController.Options := AOptions;
OptionsBehavior.IncSearch := AList.Find('edgoAutoSearch', I);
end;
except
on EcxUnknownProperty do;
end;
finally
AList.Free;
Converter.DisablePropertyException;
end;
end;
procedure TcxRealConverterToTableView.ImportDXOptionsCustomize;
var
AList: TStringList;
I: Integer;
begin
AList := TStringList.Create;
try
Converter.EnablePropertyException;
try
Converter.GetSetProperty(nil, 'OptionsCustomize', AList);
AList.Sort;
with cxGridView do
begin
OptionsCustomize.ColumnMoving := AList.Find('edgoColumnMoving', I);
OptionsCustomize.ColumnHorzSizing := AList.Find('edgoColumnSizing', I);
OptionsCustomize.ColumnHiding := AList.Find('edgoExtCustomizing', I);
end;
except
on EcxUnknownProperty do;
end;
finally
AList.Free;
Converter.DisablePropertyException;
end;
end;
procedure TcxRealConverterToTableView.ImportDXOptionsDB;
var
AList: TStringList;
I: Integer;
begin
AList := TStringList.Create;
try
Converter.EnablePropertyException;
try
Converter.GetSetProperty(nil, 'OptionsDB', AList);
AList.Sort;
with cxGridView do
begin
OptionsData.Appending := AList.Find('edgoCanAppend', I);
OptionsData.CancelOnExit := AList.Find('edgoCancelOnExit', I);
OptionsData.Deleting := AList.Find('edgoCanDelete', I);
OptionsData.Inserting := AList.Find('edgoCanInsert', I);
OptionsData.DeletingConfirmation := AList.Find('edgoConfirmDelete', I);
OptionsBehavior.FocusFirstCellOnNewRecord := AList.Find('edgoResetColumnFocus', I);
ImportSyncMode(AList.Find('edgoCanNavigation', I));
end;
except
on EcxUnknownProperty do;
end;
finally
AList.Free;
Converter.DisablePropertyException;
end;
end;
procedure TcxRealConverterToTableView.ImportDXOptionsView;
var
AList: TStringList;
begin
AList := TStringList.Create;
try
Converter.EnablePropertyException;
try
Converter.GetSetProperty(nil, 'OptionsView', AList);
AList.Sort;
AssignDXOptionsView(AList);
except
on EcxUnknownProperty do;
end;
finally
AList.Free;
Converter.DisablePropertyException;
end;
end;
procedure TcxRealConverterToTableView.ImportGrid;
begin
AssignGrid;
ImportPreview;
ImportDXOptionsDB;
ImportDXOptionsCustomize;
ImportDXOptionsBehavior;
ImportSummaryGroups;
ImportColumnSummaryGroups;
end;
procedure TcxRealConverterToTableView.ImportGridStyles;
var
AStyle: TcxCustomStyle;
AGroupNodeColor: Integer;
AGroupNodeTextColor: Integer;
AGroupPanelColor: Integer;
AGroupPanelFontColor: Integer;
AAutoSearchColor: Integer;
AAutoSearchTextColor: Integer;
APreviewFont: TFont;
AHighlightColor: Integer;
AHighlightTextColor: Integer;
AHideSelectionColor: Integer;
AHideSelectionTextColor: Integer;
AGridLineColor: Integer;
begin
FColor := Converter.GetIntegerProperty(nil, 'Color');
FFont := Converter.GetClassProperty(nil, 'Font') as TFont;
if (FColor <> clWindow) or not DefaultFont(FFont) then
begin
AStyle := Converter.CreateStyleItem;
(AStyle as TcxStyle).Color := FColor;
(AStyle as TcxStyle).Font.Assign(FFont);
(AStyle as TcxStyle).TextColor := (AStyle as TcxStyle).Font.Color;
cxGridView.Styles.Content := AStyle as TcxStyle;
end;
AGroupNodeColor := Converter.GetIntegerProperty(nil, 'GroupNodeColor');
AGroupNodeTextColor := Converter.GetIntegerProperty(nil, 'GroupNodeTextColor');
if (AGroupNodeColor <> clBtnFace) or (AGroupNodeTextColor <> clNone) then
begin
if (AGroupNodeColor = FColor) and ((AGroupNodeTextColor = FFont.Color) or
(AGroupNodeTextColor = clNone)) then
cxGridView.Styles.Group := cxGridView.Styles.Content
else
begin
AStyle := Converter.CreateStyleItem;
(AStyle as TcxStyle).Color := AGroupNodeColor;
(AStyle as TcxStyle).Font.Assign(FFont);
if AGroupNodeTextColor = clNone then
(AStyle as TcxStyle).TextColor := (AStyle as TcxStyle).Font.Color
else
(AStyle as TcxStyle).TextColor := AGroupNodeTextColor;
cxGridView.Styles.Group := AStyle as TcxStyle;
end;
end;
AGroupPanelColor := Converter.GetIntegerProperty(nil, 'GroupPanelColor');
AGroupPanelFontColor := Converter.GetIntegerProperty(nil, 'GroupPanelFontColor');
if (AGroupPanelColor <> clBtnShadow) or (AGroupPanelFontColor <> clBtnFace) then
begin
AStyle := Converter.CreateStyleItem;
(AStyle as TcxStyle).Color := AGroupPanelColor;
(AStyle as TcxStyle).TextColor := AGroupPanelFontColor;
cxGridView.Styles.GroupByBox := AStyle as TcxStyle;
end;
FHeaderColor := Converter.GetIntegerProperty(nil, 'HeaderColor');
FHeaderFont := Converter.GetClassProperty(nil, 'HeaderFont') as TFont;
if (FHeaderColor <> clBtnFace) or not DefaultFont(FHeaderFont) then
begin
AStyle := Converter.CreateStyleItem;
(AStyle as TcxStyle).Color := FHeaderColor;
(AStyle as TcxStyle).Font.Assign(FHeaderFont);
(AStyle as TcxStyle).TextColor := (AStyle as TcxStyle).Font.Color;
cxGridView.Styles.Header := AStyle as TcxStyle;
cxGridView.Styles.Indicator := AStyle as TcxStyle;
end;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?