Class GridControlBaseImp
Implements a grid control that displays a grid model.
Inheritance
Implements
Inherited Members
Namespace: Syncfusion.Windows.Forms.Grid
Assembly: Syncfusion.Grid.Windows.dll
Syntax
public class GridControlBaseImp : GridControlBase, IDisposable, ICancelModeProvider, ISplitterPaneSupport, IScrollBarWrapperContainer, ISupportUpdating, ISupportIntelliMouse, IQueryFocusInside, INonClientPaintingSupport, IThemedControl, ICreateNewWindow, IGridModelSource, IGridWindowlessSite, IGridWindowlessObject, IFindParentForm, IThemeProvider, IVisualStyle
Remarks
GridControlBase implements a view on a GridModel. Several views can be opened for the same model. Changes in GridModel are reflected immediately among all views.
The GridModel provides storage for all data and settings associated with the grid. The GridControlBase implements user interaction and display of the data.
GridControlBase is a user control that is derived from ScrollControl. It lets the user scroll through grid data with mouse or keyboard. The grid displays a large number of cells where each cell can have its own unique formatting and cell type.
GridControlBase also offers a wide range of events that let you customize the default behavior of the grid at run-time.
note
In version 1.x, the GC class did derive directly from GridControlBase. Version 2.x derives GridControl from GridControlBaseImp. If you do have classes that derive directly from GridControlBase, your code will break. Please read the following explanation.
If you derived directly from GridControlBase in your code, it is recommended that you change your code such that you derive from GridControlBaseImp instead.
If you derived from the GridControl class, no action is required on your side.
Here is why:
In Version 1.x, the GridControlBase class did by default initialize all MouseControllers and CellTypes.
We changed this now such that the GridControlBase class will only initialize the very basic cell types and mouse controllers. This step will help us later make the grid more modular and provide techniques to trim down the size of the grid assembly if you only need a subset of the features or also if we want to make parts of the grid work without interop code. The idea was to have a grid base class that only has minimal dependencies on other classes. If you have the grid source code and look at the grid\src tree, you will notice a "Base" folder and an "Extensions" folder. "Base" contains all essential files for a bare grid. "Extensions" contains all the files to make it a full-featured grid.
In order to keep compatibility with existing code, the GridControlBaseImp class has been added. GridControlBaseImp is derived from GridControlBase and its sole purpose is to initialize all mouse controllers and cell types and establish other dependencies on grid features.
If you derived directly from GridControlBase in your code base, it is recommended that you change your code such that you derive from GridControlBaseImp instead. Then your code should work without further change. Otherwise you need to manually initialize MouseControllers and cell types.
The GridControl class itself has been changed such that it derives from GridControlBaseImp. Therefore if you were using the GridControl class no further change is necessary on your side.
Here is a list of differences between GridControlBaseImp and GridControlBase:
-
GridControlBaseImp sets up the GridCellModelFactory as default cell type factory. GridControlBase on the other hand only sets up GridBaseCellModelFactory. GridCellModelFactory is able to instantiate the whole range of cell types that are part of Essential Grid. GridBaseCellModelFactory on the other hand only has dependencies on Header, Static, TextBox, ComboBox, and PushButton.
So, if your code derives from GridControlBase directly and some celltypes do not appear to get instantiated, you should add cell types manually to the CellModels collection or derive from GridControlBaseImp.
- GridControlBaseImp overrides the InitializeMouseControllers method. In this override it checks Model.Options.ControllerOptions and instantiates all mouse controllers that have been specified in this flag. GridControlBase on the other hand does not perform any action in InitializeMouseControllers.
Other features that are implemented in GridControlBaseImp and not GridControlBase are:
- The AccessibilityEnabled property. GridControlBase itself has no Accessibility support.
- Multiple cell selection.
- OLE drag-and-drop
- Cell tips
Again, if you derived from GridControl, no action is required. If you derived from GridControlBase, please change your code to derive from GridControlBaseImp instead.
The change is mainly a preparation to make it easier for us in future. We try hard not to break existing code. Providing a GridControlBaseImp class seemed like a good, easy solution and will help us in the future make the grid more modular.
Constructors
GridControlBaseImp()
Initializes a new GridControlBaseImp.
Declaration
public GridControlBaseImp()
GridControlBaseImp(GridModel)
Initializes a new GridControlBaseImp and attaches it to a GridModel.
Declaration
public GridControlBaseImp(GridModel model)
Parameters
Type | Name | Description |
---|---|---|
GridModel | model | The GridModel this control is associated with. |
Properties
AccessibilityEnabled
Gets or sets a value indicating whether the control should enable its Accessibility support.
Declaration
public bool AccessibilityEnabled { get; set; }
Property Value
Type |
---|
System.Boolean |
CellToolTip
Gets or sets a reference to the ToolTip object used for displaying CellTipText as ToolTips for cells.
Declaration
public ToolTip CellToolTip { get; set; }
Property Value
Type |
---|
System.Windows.Forms.ToolTip |
PaintSelectCells
Used internally.
Declaration
public override IGridPaintSelectCells PaintSelectCells { get; }
Property Value
Type |
---|
IGridPaintSelectCells |
Overrides
Methods
CreateAccessibilityInstance()
Creates a new accessibility object for the control.
Declaration
protected override AccessibleObject CreateAccessibilityInstance()
Returns
Type | Description |
---|---|
System.Windows.Forms.AccessibleObject | A new System.Windows.Forms.AccessibleObject for the control. |
CreateCellToolTip()
Creates and initializes a ToolTip object. InitialDelay will be 500 and ReshowDelay will be set to 0 by default.
Declaration
protected virtual ToolTip CreateCellToolTip()
Returns
Type | Description |
---|---|
System.Windows.Forms.ToolTip | The initialized ToolTip object for this grid. |
CreateOleDropTarget(GridControlBase, Int32)
Creates a GridOleDropTarget object and calls GridOleDropTarget.Register. Override this method if you want to customize behavior of the GridOleDropTarget object.
Declaration
protected virtual GridOleDropTarget CreateOleDropTarget(GridControlBase grid, int flags)
Parameters
Type | Name | Description |
---|---|---|
GridControlBase | grid | The grid control |
System.Int32 | flags | Value for DragDropDropTargetFlags |
Returns
Type | Description |
---|---|
GridOleDropTarget | returns GridOleDropTarget |
Dispose(Boolean)
Unwires any events subscribed from GridCheckBoxCellRenderer.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | true to release both managed and unmanaged resources; false to release only unmanaged resources. |
Overrides
Remarks
See the documentation for the System.ComponentModel.Component class and its Dispose member.
EnableOleDataSource()
Enables OLE Data Source support for this control with default support for Text and Styles format.
Declaration
public bool EnableOleDataSource()
Returns
Type | Description |
---|---|
System.Boolean | True if support was enabled successfully; False otherwise. |
EnableOleDataSource(Int32)
Enables OLE Data Source support for this control with default support for Text and Styles format.
Declaration
public bool EnableOleDataSource(int flags)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | flags | See GridDragDropFlags for various flags that customize the OLE Data Source behavior of the grid. |
Returns
Type | Description |
---|---|
System.Boolean | True if support was enabled successfully; False otherwise. |
EnableOleDropTarget()
Enables OLE Drop Target support for this control with default support for Text and Styles format.
Declaration
public void EnableOleDropTarget()
EnableOleDropTarget(Int32)
Enables OLE Drop Target support for this control with GridDragDropFlags options specified.
Declaration
public void EnableOleDropTarget(int flags)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | flags | See GridDragDropFlags for various flags that customize the OLE Drop Target behavior of the grid. |
InitializeDataObjectConsumerOptions()
Initializes all data object consumers for this grid. See GridDataObjectConsumerOptions for default consumers that you can enable and disable through the DataObjectConsumerOptions property of the Options property.
Declaration
protected override void InitializeDataObjectConsumerOptions()
Overrides
Remarks
Controllers will be registered by the RegisterDataObjectConsumer(IGridDataObjectConsumer).
InitializeMouseControllers()
Initializes all mouse controllers for this grid. See GridControllerOptions for default mouse controllers that you can enable and disable through the ControllerOptions of the Options property.
Declaration
protected override void InitializeMouseControllers()
Overrides
Remarks
Controllers will be added and removed from MouseControllerDispatcher.
IntUpdateSelectRange()
Overridden to update the selected cells range.
Declaration
protected override void IntUpdateSelectRange()
Overrides
OnActivateToolTip(GridActivateToolTipEventArgs)
Raises the ActivateToolTip event.
Declaration
protected virtual void OnActivateToolTip(GridActivateToolTipEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
GridActivateToolTipEventArgs | e | A GridActivateToolTipEventArgs that contains the event data. |
OnMouseMove(MouseEventArgs)
Overridden to call OnCellTipsMouseMove.
Declaration
protected override void OnMouseMove(MouseEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Forms.MouseEventArgs | e | The System.Windows.Forms.MouseEventArgsthat contains event data. |
Overrides
OnQueryAllowDragColumnHeader(GridQueryDragColumnHeaderEventArgs)
Raises the OnQueryAllowDragColumnHeader(GridQueryDragColumnHeaderEventArgs) event.
Declaration
protected virtual void OnQueryAllowDragColumnHeader(GridQueryDragColumnHeaderEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
GridQueryDragColumnHeaderEventArgs | e | A GridQueryDragColumnHeaderEventArgs that contains the event data. |
Refresh(Boolean)
Forces the control to invalidate its client area and immediately redraw itself and any child controls.
Declaration
protected override void Refresh(bool fromModel)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | fromModel | True if the grid model needs to be refreshed. |
Overrides
RegisterDataObjectConsumer(IGridDataObjectConsumer)
Registers a IGridDataObjectConsumer with the grid that can participate in an OLE Drop Target operation. If you want to add support for custom clipboard formats, you should create a class that implements IGridDataObjectConsumer and register it with RegisterDataObjectConsumer(IGridDataObjectConsumer).
Declaration
public void RegisterDataObjectConsumer(IGridDataObjectConsumer consumer)
Parameters
Type | Name | Description |
---|---|---|
IGridDataObjectConsumer | consumer | An IGridDataObjectConsumer to be added to the internal collection of OLE Drop Target consumers. |
ResetMouseControllers()
Resets all mouse controllers and removes them from MouseControllerDispatcher.
Declaration
protected override void ResetMouseControllers()
Overrides
UnwireModel()
Releases listeners for the GridModel.
Declaration
protected override void UnwireModel()
Overrides
WireModel()
Sets up listeners for the GridModel and initializes mouse controllers and data object consumers.
Declaration
protected override void WireModel()
Overrides
Events
ActivateToolTip
Occurs when mouse has moved to a new cell and a ToolTip is initialized for that cell.
Declaration
public event GridActivateToolTipEventHandler ActivateToolTip
Event Type
Type |
---|
GridActivateToolTipEventHandler |
Remarks
You have two options:
- Set e.Style.CellTipText
- Or -
- Initialize the ToolTip directly (see CellToolTip property) and then set e.Cancel = true;
QueryAllowDragColumnHeader
Occurs when the user hovers the mouse over a column header or clicks on it. In your event handler, you can determine if the selected column can be dragged.
Declaration
public event GridQueryDragColumnHeaderEventHandler QueryAllowDragColumnHeader
Event Type
Type |
---|
GridQueryDragColumnHeaderEventHandler |
Remarks
You can disallow dragging the column when you assign False to AllowDrag.