mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-13 05:19:25 +02:00
IdeIntf: Prevent exception when fetching labels on TDBGridColumnsPropertyEditorForm. Issue #32864, patch from FTurtle.
git-svn-id: trunk@56858 -
This commit is contained in:
parent
3ba9674deb
commit
b561f1b752
@ -5,7 +5,11 @@ unit DBGridColumnsPropEditForm;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, Forms, ComCtrls, StdCtrls, ActnList, LCLType, typinfo, DBGrids;
|
Classes, SysUtils, typinfo, db,
|
||||||
|
// LCL
|
||||||
|
Controls, Dialogs, LCLProc, Forms, ComCtrls, StdCtrls, ActnList, LCLType, DBGrids,
|
||||||
|
// IdeIntf
|
||||||
|
IDEImagesIntf, ObjInspStrConsts, PropEdits, PropEditUtils;
|
||||||
|
|
||||||
type
|
type
|
||||||
{ TDBGridColumnsPropertyEditorForm }
|
{ TDBGridColumnsPropertyEditorForm }
|
||||||
@ -71,14 +75,8 @@ implementation
|
|||||||
|
|
||||||
{$R *.lfm}
|
{$R *.lfm}
|
||||||
|
|
||||||
uses
|
|
||||||
Controls, Dialogs, LCLProc, IDEImagesIntf, ObjInspStrConsts, PropEdits,
|
|
||||||
PropEditUtils;
|
|
||||||
|
|
||||||
type
|
type
|
||||||
TPersistentAccess = class(TPersistent)
|
TPersistentAccess = class(TPersistent);
|
||||||
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TDBGridColumnsPropertyEditorForm.FormCreate(Sender: TObject);
|
procedure TDBGridColumnsPropertyEditorForm.FormCreate(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
@ -277,24 +275,27 @@ begin
|
|||||||
UpdateCaption;
|
UpdateCaption;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDBGridColumnsPropertyEditorForm.actFetchLabelsExecute(Sender: TObject
|
procedure TDBGridColumnsPropertyEditorForm.actFetchLabelsExecute(Sender: TObject);
|
||||||
);
|
var
|
||||||
var It : TColumn;
|
Column: TColumn;
|
||||||
i : Integer;
|
DataSet: TDataSet;
|
||||||
|
Field: TField;
|
||||||
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
//
|
if (FOwnerPersistent as TDBGrid).DataSource=nil then Exit;
|
||||||
if (Collection.Count > 0) and ( MessageDlg( dceColumnEditor, dceWillReplaceContinue,
|
DataSet:=TDBGrid(FOwnerPersistent).DataSource.DataSet;
|
||||||
mtConfirmation, [mbYes, mbNo], 0) = mrYes ) then begin
|
if DataSet=nil then Exit;
|
||||||
|
|
||||||
It := TColumn (Collection.Items[ 0 ]);
|
if MessageDlg(dceColumnEditor, dceWillReplaceContinue, mtConfirmation,
|
||||||
if Assigned ( It.Grid ) and Assigned (TDBGrid(It.Grid).DataSource) and Assigned (TDBGrid(It.Grid).DataSource.DataSet) then begin
|
[mbYes, mbNo], 0)<>mrYes then Exit;
|
||||||
for i := 0 to Collection.Count - 1 do
|
|
||||||
TColumn(Collection.Items[ i ]).Title.Caption:=TDBGrid(TColumn(Collection.Items[I]).Grid).DataSource.DataSet.FieldByName( TColumn(Collection.Items[I]).FieldName ).DisplayLabel;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
for i:=0 to FCollection.Count-1 do
|
||||||
|
begin
|
||||||
|
Column:=FCollection.Items[i] as TColumn;
|
||||||
|
Field:= DataSet.FindField(Column.FieldName);
|
||||||
|
if Field<>nil then
|
||||||
|
Column.Title.Caption:=Field.DisplayLabel;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDBGridColumnsPropertyEditorForm.actMoveDownExecute(Sender: TObject);
|
procedure TDBGridColumnsPropertyEditorForm.actMoveDownExecute(Sender: TObject);
|
||||||
|
Loading…
Reference in New Issue
Block a user