TGridOptions and TGridOption customize the appearance and behavior of a grid control.
TGridOptions = set of TGridOption;
TGridOption TGridOptions;
TGridOptions is a set of TGridOption values. The following table lists the possible TGridOption values:
Value |
Meaning |
goFixedVertLine |
Vertical lines are drawn to separate the fixed (nonscrolling) columns in the grid. |
goFixedHorzLine |
Horizontal lines are drawn to separate the fixed (nonscrolling) rows in the grid. |
goVertLine |
Vertical lines are drawn to separate the scrollable columns in the grid. |
goHorzLine |
Horizontal lines are drawn to separate the scrollable rows in the grid. |
goRangeSelect |
Users can select ranges of cells at one time. goRangeSelect is ignored if Options includes goEditing. |
goDrawFocusSelected |
Cells with input focus are drawn with a special highlight color, just like selected cells without input focus. If goDrawFocusSelected is not included, the cell with input focus is distinguished by a focus rectangle, not by a special background color. |
goRowSizing |
Scrollable rows can be individually resized. |
goColSizing |
Scrollable columns can be individually resized. |
goRowMoving |
Scrollable rows can be moved using the mouse. |
goColMoving |
Scrollable columns can be moved using the mouse. |
goEditing |
Users can edit the contents of cells. When goEditing is included in Options, goRangeSelect has no effect. |
goTabs |
Users can navigate through the cells in the grid using Tab and Shift+Tab. |
goRowSelect |
Entire rows are selected rather than individual cells. If goRowSelect is included in Options, goAlwaysShowEditor has no effect. |
goAlwaysShowEditor |
The grid is locked into edit mode. The user does not need to use Enter or F2 to turn on EditorMode. If Options does not include goEditing, goAlwaysShowEditor has no effect. If Options includes goRowSelect, goAlwaysShowEditor has no effect. |
goThumbTracking |
The grid image updates while the user is dragging the thumb of the scroll bar. If goThumbTracking is not included, the image does not update until the user releases the thumb in a new position. |
C++ Examples:
/* The following code uses the bitmaps in an image list component to draw the contents of each cell in a draw grid. It draws a focus rectangle around the cell that has focus. goDrawFocusSelect in the DrawGrid Options parameter must be True to set focus on a cell. The ImageList Draw method must be called after DrawFocusRect. The OnSelectCell event handler must implemented to return true. */ void __fastcall TForm1::DrawGrid1DrawCell( TObject *Sender, int ACol, int ARow, TRect &Rect, TGridDrawState State) { long index = ARow * DrawGrid1->ColCount + ACol; DrawGrid1->Canvas->Brush->Color = clBackground; DrawGrid1->Canvas->FillRect(Rect); if (State.Contains(gdFocused)) { DrawGrid1->Canvas->DrawFocusRect(Rect); Label1->Caption = "Cell " + IntToStr(int(index)) + " has the focus."; } ImageList1->Draw( DrawGrid1->Canvas, Rect.Left, Rect.Top, index, True); } void __fastcall TForm1::DrawGrid1SelectCell(TObject *Sender, int ACol, int ARow, bool &CanSelect) { CanSelect= True; }
Delphi Examples:
{ The following code uses the bitmaps in an image list component to draw the contents of each cell in a draw grid. It draws a focus rectangle around the cell that has focus. goDrawFocusSelect in the DrawGrid Options parameter must be True to set focus on a cell. The ImageList Draw method must be called after DrawFocusRect. The OnSelectCell event handler must implemented to return true. } procedure TForm1.DrawGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); var index: Integer; begin index := ARow * DrawGrid1.ColCount + ACol; DrawGrid1.Canvas.Brush.Color := clWhite; DrawGrid1.Canvas.FillRect(Rect); if (gdFocused in State) then begin DrawGrid1.Canvas.DrawFocusRect(Rect); Label1.Caption:= 'Cell ' + InttoStr(index) + ' has the focus.'; end; ImageList1.Draw(DrawGrid1.Canvas,Rect.Left,Rect.Top,index, True); end; procedure TForm1.DrawGrid1SelectCell(Sender: TObject; ACol, ARow: Integer; var CanSelect: Boolean); begin CanSelect:= True; end;
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|