Class GridDropDownGridListControlCellRenderer
Defines the renderer part of a drop-down ListControl-like grid that lets users drop-down a grid that can be bound to a DataSource of a GridStyleInfo instance and supports auto-complete. Display and value members can be specified with ValueMember and DisplayMember.
Inheritance
Inherited Members
Namespace: Syncfusion.Windows.Forms.Grid
Assembly: Syncfusion.Grid.Windows.dll
Syntax
public class GridDropDownGridListControlCellRenderer : GridDropDownCellRenderer, IQueryFocusInside, IGridDropDownCell, IPopupParent, IPopupItem, IDisposable
Remarks
The GridDropDownGridListControlCellRenderer supports an auto complete feature that will fill the text with possible matches from the drop-down list while the user is entering text.
A renderer is created for each GridCellModelBase and GridControlBase. There can be several renderers associated with one GridDropDownGridListControlCellModel if several views display the same GridModel.
The following table lists some characteristics about the DropDownGridListControl cell type.
Item | Description |
---|---|
CellType | GridListControl |
Renderer | GridDropDownGridListControlCellRenderer |
Model | GridDropDownGridListControlCellModel |
XP Themes Support | Yes |
Cell Button | GridCellComboBoxButton |
Interactive | Edit with Text Input or DropDown |
Control | GridDropDownEditPartControl |
DropDown Control | GridListControl |
Floating Support | No |
Base Type | GridDropDownCellRenderer |
The cell's behavior and appearance can be customized with the following properties of the GridStyleInfo class:
PropertyName | Description |
---|---|
AllowEnter (System.Boolean) | Gets / sets if pressing the <Enter>-Key should insert a new line into the edited text. (Default: False) |
BaseStyle (System.String) | The base style for this style instance with default values for properties that are not initialized for this style object. (Default: String.Empty) |
Borders (GridBordersInfo) | Top, left, bottom, and right border settings. (Default: GridBordersInfo.Default) |
CellAppearance (GridCellAppearance) | Specifies if cell edges shall be drawn raised, sunken, or flat (default). (Default: GridCellAppearance.Flat) |
CellTipText (System.String) | ToolTip text to be displayed when user hovers mouse over cell. (Default: String.Empty) |
CellType (System.String) | GridListControl (Default: Text Box) |
CellValue (System.Object) | This property holds the cell value. Although the cell value is typically a string, it can also be any other primitive type such as int, byte, enum, or any custom type that is derived from System.Object. (Default: String.Empty) |
CellValueType (System.Type) | Specifies the preferred System.Type for cell values. When you assign a value to the GridStyleInfo object, the value will be converted to this type. If the value cannot be converted, Error will contain error information. (Default: NULL) |
Clickable (System.Boolean) | Specifies if the drop-down button can be clicked. If set to False, the button will be drawn grayed out. See Enabled how to disable activating the drop-down cell. (Default: True) |
CultureInfo (System.Globalization.CultureInfo) | The culture information holds rules for parsing and formatting the cell's value. (Default: NULL) |
DataSource (System.Object) | Specifies a data source that holds items to be displayed in a drop-down list. A datasource can be specified instead of manually filling the choicelist with string entries. (Default: NULL) |
DisplayMember (System.String) | Names the property in the DataSource that holds the text to be displayed in a cell that depends on a ValueMember. (Default: String.Empty) |
DropDownStyle (GridDropDownStyle) | Specifies if user input is restricted to items from the ChoiceList or DataSource. (Default: GridDropDownStyle.Editable) |
Enabled (System.Boolean) | Specifies if the cell can be activated as current cell or if the cell should be skipped when moving the current cell. When disabled, the drop-down button can still be clicked. You should also disable Clickable if you do not want the user to click the drop-down button. (Default: True) |
Error (System.String) | Holds error information if a value could not be converted to the System.Type specified with CellValueType. (Default: String.Empty) |
ExclusiveChoiceList (System.Boolean) | Specifies if user input is restricted to items from the ChoiceList or DataSource. (Default: False) |
Font (GridFontInfo) | The font for drawing text. (Default: GridFontInfo.Default) |
HorizontalAlignment (GridHorizontalAlignment) | Specifies horizontal alignment of text in the cell. This does not affect the position of the drop-down button. (Default: GridHorizontalAlignment.Left) |
HotkeyPrefix (System.Drawing.Text.HotkeyPrefix) | Specifies how hot-key prefixes should be displayed. Hot-keys are indicated in text with an '&' (ampersand). When you enable the hot-key prefix, the specific characters can be displayed underlined or regular. The '&' will not be displayed. (Default: HotkeyPrefix.Show) |
ImageIndex (System.Int32) | Specifies an index for an image in the ImageList of a GridStyleInfo instance. The image is only shown in the text field, not in the drop-down list. You have to add custom programming logic in order to set the ImageIndex based on a selection in the drop-down list. (Default: -1) |
ImageList (System.Windows.Forms.ImageList) | The ImageList that holds a collection of images. Cells can choose images with the ImageIndex property in a GridStyleInfo instance. (Default: NULL) |
Interior (BrushInfo) | Lets you specify a solid backColor, gradient, or pattern style with both back and foreColor for a cell's background. (Default: SystemColors.Window) |
MaxLength (System.Int32) | Limits the number of characters the user can type into the cell. Note: When selecting a text from a choice list or when pasting text, the text can be longer. Additional validation is necessary on your side. (Default: 0) |
ReadOnly (System.Boolean) | Specifies if cell contents can be modified by the user. The user can still drop-down the grid panel but changes will not be saved back into the text field. (Default: False) |
ShowButtons (GridShowButtons) | Specifies when to show or display the drop-down button. Possible choices are: show the button only for the current cell, always show buttons, or never show buttons. (Default: GridShowButtons.Show) |
Text (System.String) | Gets / sets the value as a string. If a CellValueType is specified, the text will be parsed and converted to the type specified with CellValueType using any CultureInfo information. (Default: String.Empty) |
TextAlign (GridTextAlign) | Align text left of button elements (which is typical for combo boxes). Or align text right of button elements. (Default: GridTextAlign.Default) |
TextColor (System.Drawing.Color) | Lets you specify the color for drawing the cell text. (Default: SystemColors.WindowText) |
TextMargins (GridMarginsInfo) | Holds text margins in pixels. When drawing a cell, this specifies the empty area between the text rectangle and the borders of the client rectangle of the cell. The client rectangle is the cell rectangle without buttons and borders. (Default: GridMarginsInfo.Default) |
Themed (System.Boolean) | Specifies if cell should be drawn using Windows XP themes when ThemesEnabled has been set. (Default: True) |
Trimming (System.Drawing.StringTrimming) | Indicates how text is trimmed when it exceeds the edges of the cell text rectangle. (Default: StringTrimming.Character) |
ValidateValue (GridCellValidateValueInfo) | Holds validation rules for the cell value that are being checked before any user changes are committed to the grid cells style object. (Default: NULL) |
ValueMember (System.String) | Names the property in the dataSource that holds the key to be saved in a cell. (Default: String.Empty) |
VerticalAlignment (GridVerticalAlignment) | Specifies the vertical alignment of text and the drop-down button in the cell. (Default: GridVerticalAlignment.Top) |
WrapText (System.Boolean) | Specifies if text should be wrapped when it does not fit into a single line. (Default: True) |
Constructors
GridDropDownGridListControlCellRenderer(GridControlBase, GridCellModelBase)
Initializes a new GridDropDownGridListControlCellRenderer object for the given GridControlBase and GridCellModelBase.
Declaration
public GridDropDownGridListControlCellRenderer(GridControlBase grid, GridCellModelBase cellModel)
Parameters
Type | Name | Description |
---|---|---|
GridControlBase | grid | The GridControlBase that displays this cell renderer. |
GridCellModelBase | cellModel | The GridCellModelBase that holds data for this cell renderer that should be shared among views. |
Remarks
References to GridControlBase, and GridCellModelBase will be saved.
Properties
ListControlPart
Gets the grid that is displayed in the drop-down window.
Declaration
public GridListControl ListControlPart { get; }
Property Value
Type |
---|
GridListControl |
Model
Gets the GridDropDownGridListControlCellModel that this cell renderer belongs to.
Declaration
public GridDropDownGridListControlCellModel Model { get; }
Property Value
Type |
---|
GridDropDownGridListControlCellModel |
Methods
CreateListControlPart()
Creates the grid that is displayed in the drop-down window.
Declaration
protected virtual GridListControl CreateListControlPart()
Returns
Type | Description |
---|---|
GridListControl | A GridListControl to be placed in the dropdown container. |
Dispose(Boolean)
Unwires any events subscribed from GridDropDownListControlCellRenderer.
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.
DropDownContainerShowedDropDown(Object, EventArgs)
Occurs after the popup child was dropped down and made visible.
Declaration
public override void DropDownContainerShowedDropDown(object sender, EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Object | sender | The control source. |
System.EventArgs | e | The System.EventArgsthat contains event data. |
Overrides
DropDownContainerShowingDropDown(Object, CancelEventArgs)
Occurs when the drop down container is about to be shown.
Declaration
public override void DropDownContainerShowingDropDown(object sender, CancelEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Object | sender | The control source. |
System.ComponentModel.CancelEventArgs | e | The System.ComponentModel.CancelEventArgsthat contains event data. |
Overrides
FindItem(String, Boolean, Int32, Boolean)
Searches for a given prefix at a starting index in the drop-down list.
Declaration
public virtual int FindItem(string prefix, bool selectItem, int start, bool ignoreCase)
Parameters
Type | Name | Description |
---|---|---|
System.String | prefix | The prefix to search for. |
System.Boolean | selectItem | True if found entry should be selected in list box. |
System.Int32 | start | The index where to start the search. |
System.Boolean | ignoreCase | True if case can be ignored; False if case sensitive. |
Returns
Type | Description |
---|---|
System.Int32 | The index of the entry that matches the prefix. |
FindItemExact(String, Boolean, Int32, Boolean)
Finds text in the list box.
Declaration
public virtual int FindItemExact(string text, bool selectItem, int start, bool ignoreCase)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text (or prefix) to find. |
System.Boolean | selectItem | True if you want to select the text in the list box. |
System.Int32 | start | The first index to start searching. |
System.Boolean | ignoreCase | True if case can be ignored; False if case sensitive. |
Returns
Type | Description |
---|---|
System.Int32 | The index of the entry that starts with the text; -1 if no entry could be found. |
InitializeDropDownContainer()
Called to initialize contents of the drop-down container for the first time.
Declaration
protected override void InitializeDropDownContainer()
Overrides
ListControlGotFocus(Object, EventArgs)
Handles the System.Windows.Forms.Control.GotFocus event for the list box, resets mouse tracking.
Declaration
public virtual void ListControlGotFocus(object sender, EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Object | sender | The source control |
System.EventArgs | e | The System.EventArgsthat contains event data. |
ListControlGridCellDrawn(Object, GridDrawCellEventArgs)
Event handler for CellDrawn event of dropdown table.
Declaration
protected virtual void ListControlGridCellDrawn(object sender, GridDrawCellEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Object | sender | Event source. |
GridDrawCellEventArgs | e | The GridDrawCellEventArgsthat contains event data. |
ListControlGridPrepareViewStyleInfo(Object, GridPrepareViewStyleInfoEventArgs)
Event handler for PrepareViewStyleInfo event of dropdown table.
Declaration
protected virtual void ListControlGridPrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Object | sender | Event source. |
GridPrepareViewStyleInfoEventArgs | e | The GridPrepareViewStyleInfoEventArgsthat contains event data. |
ListControlMouseUp(Object, MouseEventArgs)
Handles the System.Windows.Forms.Control.MouseUp event for the list box, closes the drop-down.
Declaration
public virtual void ListControlMouseUp(object sender, MouseEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Object | sender | The source control. |
System.Windows.Forms.MouseEventArgs | e | The System.Windows.Forms.MouseEventArgsthat contains event data. |
ListControlScroll(Object, ScrollEventArgs)
Handles the vertical Scroll event for the dropped-down grid and sets focus to the drop-down.
Declaration
public virtual void ListControlScroll(object sender, ScrollEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Object | sender | The source control. |
System.Windows.Forms.ScrollEventArgs | e | The System.Windows.Forms.ScrollEventArgsthat contains event data. |
NotifyCurrentCellChanged()
Raises the GridCurrentCell.CellChanged event indicating the contents of the current cell have been changed (e.g. in response to a TextBox.Changed event).
Declaration
protected override void NotifyCurrentCellChanged()
Overrides
Remarks
If you have implemented a custom cell type you should call this method from your derived renderer if you support modifying the cell contents.
OnClick(Int32, Int32, MouseEventArgs)
This is called from GridSelectCellsMouseController when the user clicked inside a cell.
Declaration
protected override void OnClick(int rowIndex, int colIndex, MouseEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The row index. |
System.Int32 | colIndex | The column index. |
System.Windows.Forms.MouseEventArgs | e | The System.Windows.Forms.MouseEventArgsthat contains event data. |
Overrides
OnControlDoubleClick(Control)
Occurs when the current cell has in-place editing mode and the user double-clicked inside the control associated with the current cell.
Declaration
protected override void OnControlDoubleClick(Control control)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Forms.Control | control |
Overrides
Remarks
GridCurrentCell.ControlDoubleClick lets you detect a double click inside a cell for any CurrentCellActivateBehavior. If for example the focus is set to the renderers control after the first click, the grid will listen for a MouseDown on the newly focused control and raise this event on a second click.
Raising this event is only optional for the cell renderer that manages the active cell.
A text box will usually send this event when the associated System.Windows.Forms.TextBox control has received the focus after the cell was switched into edit mode and the user double-clicked. Other cell renderers may or may not send this event.
OnDeactivating()
Closes the DropDown if the CurrentCell is deactivated along with BrowseOnly property
Declaration
protected override bool OnDeactivating()
Returns
Type |
---|
System.Boolean |
Overrides
OnDoubleClick(Int32, Int32, MouseEventArgs)
This is called from GridSelectCellsMouseController when the user double-clicks inside a cell.
Declaration
protected override void OnDoubleClick(int rowIndex, int colIndex, MouseEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The row index. |
System.Int32 | colIndex | The column index. |
System.Windows.Forms.MouseEventArgs | e | The System.Windows.Forms.MouseEventArgsthat contains event data. |
Overrides
OnEditPartMouseDown(Object, MouseEventArgs)
Handles the System.Windows.Forms.Control.MouseDown event for the text box. Selects the next item in the list if the user double-clicks.
Declaration
protected virtual void OnEditPartMouseDown(object sender, MouseEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Object | sender | The source of the event. |
System.Windows.Forms.MouseEventArgs | e | The System.Windows.Forms.MouseEventArgsthat contains event data. |
OnEnsureListControlPart()
Called after OnInitialize(Int32, Int32) created ListControlPart
Declaration
protected virtual void OnEnsureListControlPart()
OnInitialize(Int32, Int32)
This method gets called from the cell renderer's initialize method. Override this method if you need to any initialization for the current cell.
Declaration
protected override void OnInitialize(int rowIndex, int colIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The row index. |
System.Int32 | colIndex | The column index. |
Overrides
OnKeyDown(KeyEventArgs)
Declaration
protected override void OnKeyDown(KeyEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Forms.KeyEventArgs | e |
Overrides
OnKeyPress(KeyPressEventArgs)
User pressed key (similar to Control.OnKeyPress).
Declaration
protected override void OnKeyPress(KeyPressEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Forms.KeyPressEventArgs | e | A System.Windows.Forms.KeyEventArgs with data of the keyboard event. |
Overrides
OnPrepareViewStyleInfo(GridPrepareViewStyleInfoEventArgs)
Allows custom formatting of a cell by changing its style object.
Declaration
public override void OnPrepareViewStyleInfo(GridPrepareViewStyleInfoEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
GridPrepareViewStyleInfoEventArgs | e | TheGridPrepareViewStyleInfoEventArgsthat contains event data. |
Overrides
OnRejectChanges()
This is called from GridCurrentCell.RejectChanges. Any drop-downs have been closed at this time.
Declaration
protected override void OnRejectChanges()
Overrides
OnSetControlText(String)
Called right after ControlText was set.
Declaration
protected override void OnSetControlText(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The ControlText |
Overrides
ProcessMouseWheel(MouseEventArgs)
Lets you customize and redirect the mouse wheel behavior to a cell renderer.
Declaration
public override bool ProcessMouseWheel(MouseEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Forms.MouseEventArgs | e | The System.Windows.Forms.MouseEventArgs event arguments. |
Returns
Type | Description |
---|---|
System.Boolean | True if the parent grid should not be scrolled; False if the parent grid should scroll. |
Overrides
ResetListControlPart()
Called from Dispose(Boolean) to destroy ListControlPart
Declaration
protected virtual void ResetListControlPart()
SynchronizeDisplayText(Int32)
Retrieves the text from the list box index and sets the TextBoxText. Called when the user presses arrow keys to move selection in dropped list box.
Declaration
protected virtual void SynchronizeDisplayText(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | List box index. |
TextBoxChanged(Object, EventArgs)
Occurs when the System.Windows.Forms.Control.TextChanged event of the TextBox is raised.
Declaration
protected override void TextBoxChanged(object sender, EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Object | sender | The source of the event. |
System.EventArgs | e | The System.EventArgsthat contains event data. |
Overrides
ValidateString(String)
Checks whether the specified text is valid.
Declaration
public override bool ValidateString(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | Text to be validated. |
Returns
Type | Description |
---|---|
System.Boolean | True if the text is valid; False otherwise. |