TRxColumn.Option - enable show/hide column from grid column dialog

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3391 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
alexs75
2014-07-28 10:24:14 +00:00
parent afce2639bd
commit 0af501a361
3 changed files with 41 additions and 15 deletions

View File

@ -74,6 +74,9 @@ type
//TRxDBGridAllowedOperations = set of TRxDBGridAllowedOperation;
{$ENDIF}
TRxColumnOption = (coCustomizeVisible, coCustomizeWidth);
TRxColumnOptions = set of TRxColumnOption;
TRxColumnEditButtonStyle = (ebsDropDownRx, ebsEllipsisRx, ebsGlyphRx, ebsUpDownRx,
ebsPlusRx, ebsMinusRx);
@ -417,6 +420,7 @@ type
FKeyList: TStrings;
FNotInKeyListIndex: integer;
FOnDrawColumnCell: TDrawColumnCellEvent;
FOptions: TRxColumnOptions;
FSortFields: string;
FSortOrder: TSortMarker;
FSortPosition: integer;
@ -443,18 +447,18 @@ type
property SortOrder: TSortMarker read FSortOrder write FSortOrder;
property SortPosition: integer read FSortPosition;
published
property SortFields: string read FSortFields write FSortFields;
property Footer: TRxColumnFooter read GetFooter write SetFooter;
property Constraints:TRxDBGridCollumnConstraints read GetConstraints write SetConstraints;
property ImageList: TImageList read FImageList write SetImageList;
property KeyList: TStrings read GetKeyList write SetKeyList;
property NotInKeyListIndex: integer read FNotInKeyListIndex
write SetNotInKeyListIndex default -1;
property Filter: TRxColumnFilter read FFilter write SetFilter;
property DirectInput : boolean read FDirectInput write FDirectInput default true;
property EditButtons:TRxColumnEditButtons read FEditButtons write SetEditButtons;
property OnDrawColumnCell: TDrawColumnCellEvent read FOnDrawColumnCell write FOnDrawColumnCell;
property Filter: TRxColumnFilter read FFilter write SetFilter;
property Footer: TRxColumnFooter read GetFooter write SetFooter;
property ImageList: TImageList read FImageList write SetImageList;
property KeyList: TStrings read GetKeyList write SetKeyList;
property NotInKeyListIndex: integer read FNotInKeyListIndex write SetNotInKeyListIndex default -1;
property Options:TRxColumnOptions read FOptions write FOptions default [coCustomizeVisible, coCustomizeWidth];
property SortFields: string read FSortFields write FSortFields;
property WordWrap:boolean read FWordWrap write SetWordWrap default false;
property OnDrawColumnCell: TDrawColumnCellEvent read FOnDrawColumnCell write FOnDrawColumnCell;
end;
{ TRxDbGridColumns }
@ -5164,6 +5168,7 @@ begin
FFilter := TRxColumnFilter.Create(Self);
FDirectInput := true;
FEditButtons:=TRxColumnEditButtons.Create(Self);
FOptions:=[coCustomizeVisible, coCustomizeWidth];
end;
destructor TRxColumn.Destroy;

View File

@ -126,7 +126,7 @@ object rxDBGridColumsForm: TrxDBGridColumsForm
end
object btnApply: TBitBtn
AnchorSideBottom.Side = asrBottom
Left = -63
Left = -205
Height = 30
Top = 0
Width = 71
@ -173,6 +173,7 @@ object rxDBGridColumsForm: TrxDBGridColumsForm
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goEditing, goRowSelect, goRowHighlight]
TabOrder = 1
TitleStyle = tsNative
OnClick = StringGrid1Click
OnValidateEntry = StringGrid1ValidateEntry
ColWidths = (
30

View File

@ -53,6 +53,7 @@ type
procedure FormCreate(Sender: TObject);
procedure sbUpClick(Sender: TObject);
procedure sbDownClick(Sender: TObject);
procedure StringGrid1Click(Sender: TObject);
procedure StringGrid1ValidateEntry(sender: TObject; aCol, aRow: Integer;
const OldValue: string; var NewValue: String);
private
@ -159,6 +160,21 @@ begin
end;
end;
procedure TrxDBGridColumsForm.StringGrid1Click(Sender: TObject);
var
i:integer;
C:TRxColumn;
begin
i:=StringGrid1.Row;
C:=FGrid.ColumnByCaption(StringGrid1.Cells[1, i]);
if coCustomizeVisible in C.Options then
StringGrid1.Options:=StringGrid1.Options + [goEditing]
else
StringGrid1.Options:=StringGrid1.Options - [goEditing]
;
end;
procedure TrxDBGridColumsForm.StringGrid1ValidateEntry(sender: TObject; aCol,
aRow: Integer; const OldValue: string; var NewValue: String);
begin
@ -169,20 +185,24 @@ end;
procedure TrxDBGridColumsForm.SetGrid(AGrid: TRxDBGrid);
var
i:integer;
C:TRxColumn;
begin
if AGrid=FGrid then exit;
FGrid:=AGrid;
if Assigned(AGrid) then
begin
StringGrid1.RowCount:=AGrid.Columns.Count+1;
StringGrid1.RowCount:=AGrid.Columns.Count + 1;
for i:=0 to AGrid.Columns.Count-1 do
begin
StringGrid1.Cells[0, i+1]:=BoolToStr(AGrid.Columns[i].Visible, '1', '0');
StringGrid1.Cells[1, i+1]:=AGrid.Columns[i].Title.Caption;
if AGrid.Columns[i].Width = 0 then
StringGrid1.Cells[2, i+1]:=IntToStr(AGrid.DefaultColWidth)
C:=AGrid.Columns[i] as TRxColumn;
StringGrid1.Cells[0, i + 1]:=BoolToStr(C.Visible, '1', '0');
StringGrid1.Cells[1, i + 1]:=C.Title.Caption;
if C.Width = 0 then
StringGrid1.Cells[2, i + 1]:=IntToStr(AGrid.DefaultColWidth)
else
StringGrid1.Cells[2, i+1]:=IntToStr(AGrid.Columns[i].Width);
StringGrid1.Cells[2, i + 1]:=IntToStr(C.Width);
end;
end
else