cxdbextlookupcombobox.pas
来自「胜天进销存源码,国产优秀的进销存」· PAS 代码 · 共 969 行 · 第 1/3 页
PAS
969 行
ListFieldItem.Focused := True;
View.DataController.Search.Locate(ListFieldItem.Index, AFindStr);
end;
end;
procedure TcxExtLookupComboBoxProperties.LookupGridInitEvents(AOnClick, AOnFocusedRowChanged: TNotifyEvent;
AOnCloseUp: cxLookupEdit.TcxLookupGridCloseUpEvent);
begin
Grid.OnClick := AOnClick; // not impl
if View <> nil then
begin
// View.OnFocusedRecordChanged := AOnFocusedRowChanged;
Grid.OnCloseUp := AOnCloseUp;
end;
end;
procedure TcxExtLookupComboBoxProperties.LookupGridInitialize;
begin
if View = nil then
Exit;
// save options
FPrevPullFocusing := TcxCustomGridTableOptionsBehaviorAccess(View.OptionsBehavior).PullFocusing;
TcxCustomGridTableOptionsBehaviorAccess(View.OptionsBehavior).PullFocusing := True;
FPrevMultiSelect := View.OptionsSelection.MultiSelect;
View.OptionsSelection.MultiSelect := False;
FPrevImmediateEditor := View.OptionsBehavior.ImmediateEditor;
View.OptionsBehavior.ImmediateEditor := False;
if View is TcxGridTableView then
begin
FPrevColumnFiltering := TcxGridTableView(View).OptionsCustomize.ColumnFiltering;
if not FocusPopup then
TcxGridTableView(View).OptionsCustomize.ColumnFiltering := False;
end;
Grid.FPrevOnKeyDown := View.OnKeyDown;
View.OnKeyDown := Grid.ViewKeyDown;
Grid.FPrevOnMouseDown := View.OnMouseDown;
View.OnMouseDown := Grid.ViewMouseDown;
Grid.FMousePos := Point(-1, -1);
Grid.FPrevOnMouseMove := View.OnMouseMove;
View.OnMouseMove := Grid.ViewMouseMove;
Grid.FPrevOnMouseUp := View.OnMouseUp;
View.OnMouseUp := Grid.ViewMouseUp;
Grid.Editable := FocusPopup;
Grid.Levels[0].GridView := View;
FPrevIncSearch := View.OptionsBehavior.IncSearch;
if FocusPopup and AutoSearchOnPopup then
View.OptionsBehavior.IncSearch := True;
View.DataController.Search.Cancel;
end;
procedure TcxExtLookupComboBoxProperties.LookupGridInitLookAndFeel(ALookAndFeel: TcxLookAndFeel;
AColor: TColor; AFont: TFont);
begin
Grid.LookAndFeel.MasterLookAndFeel := ALookAndFeel;
Grid.Color := AColor;
Grid.Font := AFont;
end;
procedure TcxExtLookupComboBoxProperties.LookupGridLockMouseMove;
begin
Grid.PopupMouseMoveLocked := True;
end;
procedure TcxExtLookupComboBoxProperties.LookupGridMakeFocusedRowVisible;
begin
if View <> nil then
View.Controller.MakeFocusedRecordVisible;
end;
procedure TcxExtLookupComboBoxProperties.LookupGridUnlockMouseMove;
begin
Grid.MouseCapture := False;
Grid.PopupMouseMoveLocked := False;
end;
// DBLookupGrid methods
procedure TcxExtLookupComboBoxProperties.DBLookupGridBeginUpdate;
begin
if View <> nil then View.BeginUpdate;
end;
procedure TcxExtLookupComboBoxProperties.DBLookupGridCheckColumnByFieldName(const AFieldName: string);
begin
if (View <> nil) and (DataController <> nil) then
begin
if (AFieldName <> '') and (DataController.GetItemByFieldName(AFieldName) = nil) then
with View.CreateItem do
begin
Index := 0;
DataController.ChangeFieldName(Index, AFieldName);
end;
end;
end;
procedure TcxExtLookupComboBoxProperties.DBLookupGridCreateColumnsByFieldNames(const AFieldNames: string);
var
I: Integer;
AFieldNamesList: TStrings;
begin
if View <> nil then
begin
View.ClearItems;
AFieldNamesList := TStringList.Create;
try
GetFieldNames(AFieldNames, AFieldNamesList);
View.BeginUpdate;
try
for I := 0 to AFieldNamesList.Count - 1 do
DataController.ChangeFieldName(View.CreateItem.Index, AFieldNamesList[I]);
finally
View.EndUpdate;
end;
finally
AFieldNamesList.Free;
end;
end;
end;
procedure TcxExtLookupComboBoxProperties.DBLookupGridEndUpdate;
begin
if View <> nil then View.EndUpdate;
end;
function TcxExtLookupComboBoxProperties.GetDBLookupGridColumnField(AIndex: Integer): TField;
begin
if DataController <> nil then
Result := DataController.GetItemField(AIndex)
else
Result := nil;
end;
function TcxExtLookupComboBoxProperties.GetDBLookupGridColumnFieldName(AIndex: Integer): string;
begin
if DataController <> nil then
Result := DataController.GetItemFieldName(AIndex)
else
Result := '';
end;
function TcxExtLookupComboBoxProperties.GetDBLookupGridColumnIndexByFieldName(const AFieldName: string): Integer;
var
AItem: TcxCustomGridTableItem;
begin
if DataController <> nil then
begin
AItem := TcxCustomGridTableItem(DataController.GetItemByFieldName(AFieldName));
Result := AItem.Index;
end
else
Result := -1;
end;
function TcxExtLookupComboBoxProperties.GetDBLookupGridDataController: TcxDBDataController;
begin
Result := TcxDBDataController(GetLookupGridDataController);
end;
function TcxExtLookupComboBoxProperties.GetGrid: TcxExtLookupGrid;
procedure CreateGrid;
begin
FGrid := TcxExtLookupGrid.Create(nil);
FGrid.IsPopupControl := True;
FGrid.BorderStyle := cxcbsNone;
FGrid.Levels.Add;
end;
begin
if (FGrid = nil) and not FDestroying then
CreateGrid;
Result := FGrid;
end;
function TcxExtLookupComboBoxProperties.GetGridMode: Boolean;
begin
Result := inherited IsUseLookupList;
end;
function TcxExtLookupComboBoxProperties.GetListFieldIndex: Integer;
var
AItem: TcxCustomGridTableItem;
begin
if IsDefinedByLookup then
Result := GetDisplayColumnIndex
else
begin
AItem := ListFieldItem;
if AItem <> nil then
Result := AItem.Index
else
Result := -1;
end;
end;
function TcxExtLookupComboBoxProperties.GetListFieldItem: TcxCustomGridTableItem;
begin
if IsDefinedByLookup then
Result := nil
else
Result := FListFieldItem;
end;
procedure TcxExtLookupComboBoxProperties.SetGridMode(Value: Boolean);
begin
inherited IsUseLookupList := Value;
end;
procedure TcxExtLookupComboBoxProperties.SetListFieldItem(Value: TcxCustomGridTableItem);
begin
if (View <> nil) and (View.IndexOfItem(Value) = -1) then
Value := nil;
if FListFieldItem <> Value then
begin
if FListFieldItem <> nil then
FreeNotificator.RemoveSender(FListFieldItem);
FListFieldItem := Value;
if FListFieldItem <> nil then
FreeNotificator.AddSender(FListFieldItem);
if not FInCheckListFieldItem then
Changed;
end;
end;
procedure TcxExtLookupComboBoxProperties.SetView(Value: TcxCustomGridTableView);
begin
if (Value <> nil) and not IsViewSupported(Value) then Exit;
if FView <> Value then
begin
if FView <> nil then
UnlinkView(FView);
FView := Value;
if FView <> nil then
LinkView(FView);
Changed;
end;
end;
{ TcxCustomExtLookupComboBox }
class function TcxCustomExtLookupComboBox.GetPropertiesClass: TcxCustomEditPropertiesClass;
begin
Result := TcxExtLookupComboBoxProperties;
end;
function TcxCustomExtLookupComboBox.CanDropDown: Boolean;
begin
if ActiveProperties.FocusPopup then
Result := True
else
Result := inherited CanDropDown;
end;
function TcxCustomExtLookupComboBox.GetActiveProperties: TcxExtLookupComboBoxProperties;
begin
Result := TcxExtLookupComboBoxProperties(InternalGetActiveProperties);
end;
function TcxCustomExtLookupComboBox.GetProperties: TcxExtLookupComboBoxProperties;
begin
Result := TcxExtLookupComboBoxProperties(FProperties);
end;
procedure TcxCustomExtLookupComboBox.SetProperties(Value: TcxExtLookupComboBoxProperties);
begin
FProperties.Assign(Value);
end;
{ TcxDBExtLookupComboBox }
class function TcxDBExtLookupComboBox.GetDataBindingClass: TcxEditDataBindingClass;
begin
Result := TcxDBLookupEditDataBinding;
end;
function TcxDBExtLookupComboBox.GetDataBinding: TcxDBTextEditDataBinding;
begin
Result := TcxDBTextEditDataBinding(FDataBinding);
end;
procedure TcxDBExtLookupComboBox.SetDataBinding(Value: TcxDBTextEditDataBinding);
begin
FDataBinding.Assign(Value);
end;
procedure TcxDBExtLookupComboBox.CMGetDataLink(var Message: TMessage);
begin
Message.Result := Integer(GetcxDBEditDataLink(Self));
end;
{ TcxEditRepositoryExtLookupComboBoxItem }
class function TcxEditRepositoryExtLookupComboBoxItem.GetEditPropertiesClass: TcxCustomEditPropertiesClass;
begin
Result := TcxExtLookupComboBoxProperties;
end;
function TcxEditRepositoryExtLookupComboBoxItem.GetProperties: TcxExtLookupComboBoxProperties;
begin
Result := inherited Properties as TcxExtLookupComboBoxProperties;
end;
procedure TcxEditRepositoryExtLookupComboBoxItem.SetProperties(Value: TcxExtLookupComboBoxProperties);
begin
inherited Properties := Value;
end;
initialization
RegisterClasses([TcxEditRepositoryExtLookupComboBoxItem]);
GetRegisteredEditProperties.Register(TcxExtLookupComboBoxProperties,
cxSEditRepositoryExtLookupComboBoxItem);
finalization
GetRegisteredEditProperties.Unregister(TcxExtLookupComboBoxProperties);
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?