WinForms

Code Examples Upgrade Guide User Guide Demos Support Forums Download
  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class GridListControl

    Show / Hide Table of Contents

    Class GridListControl

    Implements a System.Windows.Forms.ListControl that shows data in the GridControl child window. Supports multiple columns, data binding, and selection of items similar to a list box.

    Inheritance
    System.Object
    GridListControl
    GridDropDownGridListControlPart
    GridListBox
    Implements
    IThemedControl
    System.ComponentModel.ISupportInitialize
    IThemeProvider
    IVisualStyle
    Namespace: Syncfusion.Windows.Forms.Grid
    Assembly: Syncfusion.Grid.Windows.dll
    Syntax
    public class GridListControl : ListControl, IThemedControl, ISupportInitialize, IThemeProvider, IVisualStyle
    Remarks

    Because GridListControl is derived from System.Windows.Forms.ListControl, you can easily replace an existing list box (which is also derived from ListControl) with this GridListControl.

    You can access the underlying grid control with the Grid property. The list control supports several selection modes similar to a list box.

    Constructors

    GridListControl()

    Initializes a new instance for GridListControlclass.

    Declaration
    public GridListControl()

    Fields

    DefaultItemHeight

    Specifies the default item height for an owner-drawn GridListControl.

    Declaration
    public const int DefaultItemHeight = 13
    Field Value
    Type Description
    System.Int32

    NoMatches

    Specifies that no matches are found during a search.

    Declaration
    public const int NoMatches = -1
    Field Value
    Type Description
    System.Int32

    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 Description
    System.Boolean

    AllowResizeColumns

    Gets or sets a value indicating whether the user can resize columns.

    Declaration
    public bool AllowResizeColumns { get; set; }
    Property Value
    Type Description
    System.Boolean

    AlphaBlendSelectionColor

    See AlphaBlendSelectionColor in the GridModel class for information.

    Declaration
    public Color AlphaBlendSelectionColor { get; set; }
    Property Value
    Type Description
    System.Drawing.Color
    Examples

    This example shows how to use the AlphaBlendSelectionColor property.

    // Sets the alpha blend selection color
    this.gridListControl1.AlphaBlendSelectionColor = Color.Red;
    ' Sets the alpha blend selection color
    Me.gridListControl1.AlphaBlendSelectionColor = Color.Red

    ApplyVisualStyles

    Gets or sets the Legacy styles in the Table Model Value should be false to apply ColorStyles

    Declaration
    public bool ApplyVisualStyles { get; set; }
    Property Value
    Type Description
    System.Boolean

    AutoSizeColumns

    Gets or sets a value indicating whether columns should be automatically sized to fit contents of their cells.

    Declaration
    public bool AutoSizeColumns { get; set; }
    Property Value
    Type Description
    System.Boolean

    BackColor

    Specifies the Back color used to display text in the control.

    Declaration
    public override Color BackColor { get; set; }
    Property Value
    Type Description
    System.Drawing.Color

    BackgroundImage

    Gets or sets the background image used for the control.

    Declaration
    public override Image BackgroundImage { get; set; }
    Property Value
    Type Description
    System.Drawing.Image

    BindingContext

    Gets or sets the BindingContext for the control.

    Declaration
    public override BindingContext BindingContext { get; set; }
    Property Value
    Type Description
    System.Windows.Forms.BindingContext

    BorderStyle

    Gets or sets the border style of the control.

    Declaration
    public BorderStyle BorderStyle { get; set; }
    Property Value
    Type Description
    System.Windows.Forms.BorderStyle
    Examples

    This example shows how to use the BorderStyle property.

    // Sets the border style of the grid.
    this.gridListControl1.BorderStyle = BorderStyle.FixedSingle;
    ' Sets the border style of the grid.
    Me.gridListControl1.BorderStyle = BorderStyle.FixedSingle

    CanApplyTheme

    Gets or sets a value indicating whether a SkinManager theme settings can be applied to the control.

    Declaration
    public bool CanApplyTheme { get; set; }
    Property Value
    Type Description
    System.Boolean

    The default value is true.

    Remarks

    This property must be initialized before applying the VisualTheme />

    CanOverrideStyle

    Gets or sets a value indicating whether control elements styles can be overridden by theme style settings.

    Declaration
    public bool CanOverrideStyle { get; set; }
    Property Value
    Type Description
    System.Boolean

    Default value is false.

    Remarks

    By default, the control's element styles will not be overridden by theme style settings if the style is set in sample level. If this property is enabled, element style will be overridden by theme style settings event if it is set in sample level. This property should be enabled or disabled before calling the ThemeName property of the control.

    ColorStyles

    [Deprecated] Gets or sets the VisualStyles (skins) like Office2010, Office2007, Office2003

    Declaration
    public ColorStyles ColorStyles { get; set; }
    Property Value
    Type Description
    ColorStyles
    Examples

    This example shows how to use the ColorStyles property.

    // Sets the color styles of the grid. This property doesn't depends on "ThemesEnabled" property.
    this.gridListControl1.ColorStyles = ColorStyles.Office2010Silver;
    ' Sets the color styles of the grid. This property doesn't depends on "ThemesEnabled" property.
    Me.gridListControl1.ColorStyles = ColorStyles.Office2010Silver

    CreateParams

    Gets the required creation parameters when the control handle is created.

    Declaration
    protected override CreateParams CreateParams { get; }
    Property Value
    Type Description
    System.Windows.Forms.CreateParams

    EnableTouchMode

    Gets or sets the touch mode

    Declaration
    public virtual bool EnableTouchMode { get; set; }
    Property Value
    Type Description
    System.Boolean

    FillLastColumn

    Gets or sets a value indicating whether the last column should be sized in a way that the whole client area of the grid is used.

    Declaration
    public bool FillLastColumn { get; set; }
    Property Value
    Type Description
    System.Boolean

    Font

    Gets or sets the font used to display text in the control.

    Declaration
    public override Font Font { get; set; }
    Property Value
    Type Description
    System.Drawing.Font

    ForceNonThemedBorder

    Gets or sets a value indicating whether to disable themed border drawing and instead draw a solid black border when setting BorderStyle.FixedSingle.

    Declaration
    public bool ForceNonThemedBorder { get; set; }
    Property Value
    Type Description
    System.Boolean

    ForeColor

    Gets or sets the foreground color used to display text and graphics in the control.

    Declaration
    public override Color ForeColor { get; set; }
    Property Value
    Type Description
    System.Drawing.Color

    Grid

    Gets the underlying GridControl wrapped by this ListControl class.

    Declaration
    public GridControl Grid { get; }
    Property Value
    Type Description
    GridControl

    GridVisualStyles

    Gets or sets the VisualStyles (skins) like Office2010, Office2007, Office2003

    Declaration
    public GridVisualStyles GridVisualStyles { get; set; }
    Property Value
    Type Description
    GridVisualStyles
    Examples

    This example shows how to use the GridVisualStyles property.

    // Apply the visual styles to the grid.
    // Make sure to set the "ThemesEnabled = true;
    this.gridListControl1.GridVisualStyles = GridVisualStyles.Metro;
    ' Apply the visual styles to the grid.
    ' Make sure to set the "ThemesEnabled = true;
    Me.gridListControl1.GridVisualStyles = GridVisualStyles.Metro

    GridVisualStylesDrawing

    Gets or sets the VisualStylesDrawing object

    Declaration
    public IVisualStylesDrawing GridVisualStylesDrawing { get; set; }
    Property Value
    Type Description
    IVisualStylesDrawing

    HasControlFocus

    Gets a value indicating whether OnControlGotFocus() has been called. OnControlLostFocus() resets this flag.

    Declaration
    public bool HasControlFocus { get; }
    Property Value
    Type Description
    System.Boolean

    HeaderBackColor

    Gets or sets the back color for header cells.

    Declaration
    public Color HeaderBackColor { get; set; }
    Property Value
    Type Description
    System.Drawing.Color
    Examples

    This example shows how to use the HeaderBackColor property.

    // Sets the back-color for headers.
    this.gridListControl1.HeaderBackColor = Color.Red;
    ' Sets the back-color for headers.
    Me.gridListControl1.HeaderBackColor = Color.Red

    HeaderTextColor

    Gets or sets the text color for header cells.

    Declaration
    public Color HeaderTextColor { get; set; }
    Property Value
    Type Description
    System.Drawing.Color
    Examples

    This example shows how to use the HeaderTextColor property.

    // Sets the text color of the grid.
    this.gridListControl1.HeaderTextColor = Color.White;
    ' Sets the text color of the grid.
     Me.gridListControl1.HeaderTextColor = Color.White

    ImageColumn

    Gets or sets the column that should display any optional images from the image list.

    Declaration
    public int ImageColumn { get; set; }
    Property Value
    Type Description
    System.Int32
    Examples

    This example shows how to use the ImageColumn property.

    // Sets the specified column to display images in the grid. Here "2" is the Column index.
    this.gridListControl1.ImageColumn = 2;
    ' Sets the specified column to display images in the grid. Here "2" is the Column index.
    Me.gridListControl1.ImageColumn = 2

    ImageList

    Gets or sets a list of images that can be referenced with ImageIndex properties.

    Declaration
    public ImageList ImageList { get; set; }
    Property Value
    Type Description
    System.Windows.Forms.ImageList
    Examples

    This example shows how to use the ImageList property.

    // Initializes the image list to be displayed in the grid.
    ImageList img = new ImageList();
    // Adds the image to the list.
    img.Images.Add(new Bitmap(FindImageFile(@"\...\...\...\FileName.jpg")));
    // Assigns the image-list to the grid.
    this.gridListControl1.ImageList = img;
    ' Initializes the image list to be displayed in the grid.
    Dim img As New ImageList()
    ' Adds the image to the list.
    img.Images.Add(New Bitmap(FindImageFile("\...\...\...\FileName.jpg")))
    ' Assigns the image-list to the grid.
    Me.gridListControl1.ImageList = img

    Initializing

    Gets a value indicating whether BeginInit() was called.

    Declaration
    public bool Initializing { get; }
    Property Value
    Type Description
    System.Boolean

    IsActiveControl

    Gets a value indicating whether the OnEnter(EventArgs) has been called. OnLeave(EventArgs) resets this flag.

    Declaration
    public bool IsActiveControl { get; }
    Property Value
    Type Description
    System.Boolean

    IsDeactivated

    Gets a value indicating whether OnDeactivated(EventArgs) has been called. OnEnter(EventArgs) resets this flag.

    Declaration
    public bool IsDeactivated { get; }
    Property Value
    Type Description
    System.Boolean

    IsValidated

    Gets a value indicating whether the OnValidated(EventArgs) method has been called. OnLeave(EventArgs) and OnEnter(EventArgs) reset this flag.

    Declaration
    public bool IsValidated { get; }
    Property Value
    Type Description
    System.Boolean

    IsValidating

    Gets a value indicating whether the OnValidating(CancelEventArgs) method has been called. OnLeave(EventArgs) and OnEnter(EventArgs) reset this flag.

    Declaration
    public bool IsValidating { get; }
    Property Value
    Type Description
    System.Boolean

    IsVisualStyleEnabled

    Gets a value indicating whether the visual style based theme is applied to the control and also indicates whether the theme files are referred from external assemblies or not.

    Declaration
    public bool IsVisualStyleEnabled { get; }
    Property Value
    Type Description
    System.Boolean

    Return true, if the visual style based theme is applied to the control. Otherwise returns false.

    ItemHeight

    Gets or sets the default row item height in the list control.

    Declaration
    public int ItemHeight { get; set; }
    Property Value
    Type Description
    System.Int32
    Examples

    This example shows how to use the ItemHeight property.

    // Sets the row height of the grid.
    this.gridListControl1.ItemHeight = 30;
    ' Sets the row height of the grid.
    Me.gridListControl1.ItemHeight = 30

    Items

    Gets a list with items that are displayed in the list control.

    Declaration
    public IList Items { get; }
    Property Value
    Type Description
    System.Collections.IList

    MinResizeColSize

    See MinResizeColSize in the GridModel class for information.

    Declaration
    public int MinResizeColSize { get; set; }
    Property Value
    Type Description
    System.Int32

    MinResizeRowSize

    See MinResizeRowSize in the GridModel class for information.

    Declaration
    public int MinResizeRowSize { get; set; }
    Property Value
    Type Description
    System.Int32

    MultiColumn

    Gets or sets a value indicating whether the grid should display only single or multiple columns.

    Declaration
    public bool MultiColumn { get; set; }
    Property Value
    Type Description
    System.Boolean

    Properties

    See Properties in the GridModel class for information.

    Declaration
    public GridProperties Properties { get; set; }
    Property Value
    Type Description
    GridProperties

    ResizeRowsBehavior

    See ResizeRowsBehavior in the GridModel class for information.

    Declaration
    public GridResizeCellsBehavior ResizeRowsBehavior { get; set; }
    Property Value
    Type Description
    GridResizeCellsBehavior

    ScrollAlwaysVisible

    Gets or sets a value indicating whether the vertical scroll bar is shown at all times.

    Declaration
    public bool ScrollAlwaysVisible { get; set; }
    Property Value
    Type Description
    System.Boolean

    SelectedIndex

    Specifies the index of the selected item.

    Declaration
    public override int SelectedIndex { get; set; }
    Property Value
    Type Description
    System.Int32

    SelectedItem

    Gets or sets the currently selected item in the GridListControl .

    Declaration
    public object SelectedItem { get; set; }
    Property Value
    Type Description
    System.Object

    SelectionMode

    Gets or sets the method in which items are selected in the GridListControl .

    Declaration
    public virtual SelectionMode SelectionMode { get; set; }
    Property Value
    Type Description
    System.Windows.Forms.SelectionMode
    Examples

    This example shows how to use SelectionMode property.

    // Sets the selection mode to the grid.
    this.gridListControl1.SelectionMode = SelectionMode.MultiExtended;
    ' Sets the selection mode to the grid.
    Me.gridListControl1.SelectionMode = SelectionMode.MultiExtended

    ShowColumnHeader

    Gets or sets a value indicating whether column headers should be displayed.

    Declaration
    public bool ShowColumnHeader { get; set; }
    Property Value
    Type Description
    System.Boolean

    Site

    Gets or sets the site of the control.

    Declaration
    public override ISite Site { get; set; }
    Property Value
    Type Description
    System.ComponentModel.ISite

    SupportsTransparentBackColor

    Gets or sets a value indicating whether to toggle support for Windows 2000 and Windows XP transparency. Set this to True if you want the grid to draw transparent over a background bitmap.

    Declaration
    public bool SupportsTransparentBackColor { get; set; }
    Property Value
    Type Description
    System.Boolean

    TableStyle

    Gets or sets the table style.

    Declaration
    public GridStyleInfo TableStyle { get; set; }
    Property Value
    Type Description
    GridStyleInfo

    Text

    Gets or sets the text associated with this control.

    Declaration
    public override string Text { get; set; }
    Property Value
    Type Description
    System.String

    ThemeName

    Gets or sets the theme name of the control.

    Declaration
    public string ThemeName { get; set; }
    Property Value
    Type Description
    System.String

    The default value is null.

    Remarks

    This ThemeStyle settings will be applied only when the VisualStyleBased theme has been applied to the control.

    ThemesEnabled

    Gets or sets a value indicating whether XP Themes (visual styles) should be used for this control when available.

    Declaration
    public bool ThemesEnabled { get; set; }
    Property Value
    Type Description
    System.Boolean

    ThemeStyle

    Gets or sets the GridControlVisualStyle value used to customize the appearance of the GridListControl.

    Declaration
    public GridControlVisualStyle ThemeStyle { get; set; }
    Property Value
    Type Description
    GridControlVisualStyle
    Remarks

    This ThemeStyle settings will be applied only when the VisualStyleBased theme has been applied to the control.

    TopIndex

    Gets or sets the first visible row index in the list control.

    Declaration
    public int TopIndex { get; set; }
    Property Value
    Type Description
    System.Int32

    TransparentBackground

    See TransparentBackground in the GridModel class for information.

    Declaration
    public bool TransparentBackground { get; set; }
    Property Value
    Type Description
    System.Boolean

    Updating

    Gets a value indicating whether BeginUpdate() was called.

    Declaration
    public virtual bool Updating { get; }
    Property Value
    Type Description
    System.Boolean

    Methods

    ApplyScaleToControl(Single)

    applies the scaling

    Declaration
    public void ApplyScaleToControl(float sf)
    Parameters
    Type Name Description
    System.Single sf

    Represents floating point number

    BeginInit()

    Implements the BeginInit() of the System.ComponentModel.ISupportInitialize interface.

    Declaration
    public void BeginInit()

    BeginUpdate()

    Suspends updating the list control.

    Declaration
    public void BeginUpdate()

    ClearSelected()

    Unselects all items in the GridListControl.

    Declaration
    public void ClearSelected()
    Examples

    This example shows how to clear the selected rows.

    // Clears the selection done in the grid.
    this.gridListControl1.ClearSelected();
    ' Clears the selection done in the grid.
    Me.gridListControl1.ClearSelected()

    CreateGridChild()

    Creates the grid child.

    Declaration
    protected virtual GridListControlChild CreateGridChild()
    Returns
    Type Description
    GridListControlChild

    returns GridListControlChild

    CreateGridColumn(PropertyDescriptor, Int32)

    Creates a column for a given System.ComponentModel.PropertyDescriptor from the datasource.

    Declaration
    public virtual void CreateGridColumn(PropertyDescriptor pd, int column)
    Parameters
    Type Name Description
    System.ComponentModel.PropertyDescriptor pd

    The System.ComponentModel.PropertyDescriptor with column information.

    System.Int32 column

    The column index in the grid.

    Examples

    This example shows how to create a new column in the grid.

    // Creates a new column in the grid.
    PropertyDescriptor propertyDesc = this.gridListControl1.GetColumnStyle(2).Tag as PropertyDescriptor;
    this.gridListControl1.CreateGridColumn(propertyDesc, 4);
    ' Creates a new column in the grid.
    Dim propertyDesc As PropertyDescriptor = TryCast(Me.gridListControl1.GetColumnStyle(2).Tag, PropertyDescriptor)
    Me.gridListControl1.CreateGridColumn(propertyDesc, 4)

    Dispose(Boolean)

    Releases all resources used by the System.ComponentModel.Component.

    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.

    Remarks

    See the documentation for the System.ComponentModel.Component class and its Dispose member.

    EndInit()

    Implements the System.ComponentModel.ISupportInitialize.EndInit of the System.ComponentModel.ISupportInitialize interface.

    Declaration
    public void EndInit()

    EndUpdate()

    Resumes updating the list control after a BeginUpdate(), calls PerformLayout in grid.

    Declaration
    public void EndUpdate()

    FindItem(String, Boolean, Int32, Boolean)

    Finds text in the list box.

    Declaration
    public virtual int FindItem(string prefix, bool selectItem, int start, bool ignoreCase)
    Parameters
    Type Name Description
    System.String prefix

    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.

    Examples

    This example shows how to get the index of the specified string value considering to select the row or not and also whether to consider the case with the search-from index.

    // Finds the specified string in the grid and returns it's index value.
    // If the string case should be ignored, then the last parameter should be "true"
    int foundedItem=this.gridListControl1.FindItem("o", true, 1, true);
    Console.WriteLine("The item is found in the index  " + foundedItem);
    ' Finds the specified string in the grid and returns it's index value.
    ' If the string case should be ignored, then the last parameter should be "true"
    Dim foundedItem As Integer=Me.gridListControl1.FindItem("o", True, 1, True)
    Console.WriteLine("The item is found in the index  " & foundedItem)

    FindString(String)

    Finds the first item in the GridListControl that starts with the specified string.

    Declaration
    public int FindString(string s)
    Parameters
    Type Name Description
    System.String s

    The text to search for.

    Returns
    Type Description
    System.Int32

    The zero-based index of the first item found; returns langword_csharp_ListBox.NoMatches if no match is found.

    Examples

    This example shows how to get the index of the specified string value.

    // Finds the specified string in the grid and returns it's index value.
    // The string is considered as case-insensitive.
    int foundedItem = this.gridListControl1.FindString("Texas");
    Console.WriteLine("The specified string is found in the index  " + foundedItem);
    ' Finds the specified string in the grid and returns it's index value.
    ' The string is considered as case-insensitive.
    Dim foundedItem As Integer = Me.gridListControl1.FindString("Texas")
    Console.WriteLine("The specified string is found in the index  " & foundedItem)

    FindString(String, Int32)

    Finds the first item in the GridListControl that starts with the specified string. The search starts at a specific starting index.

    Declaration
    public int FindString(string s, int startIndex)
    Parameters
    Type Name Description
    System.String s

    The text to search for.

    System.Int32 startIndex

    The zero-based index of the item before the first item to be searched. Set to negative one (-1) to search from the beginning of the control.

    Returns
    Type Description
    System.Int32

    The zero-based index of the first item found; returns langword_csharp_ListBox.NoMatches if no match is found.

    Examples

    This example shows how to get the index of the specified string value and considering the search-from row index.

    // Finds the specified string in the grid from a specific index to start the search and returns it's index value. 
    // The string is considered as case-insensitive.
    int foundedItem = this.gridListControl1.FindString("Texas", 5);
    Console.WriteLine("The specified string is found in the index  " + foundedItem);
    ' Finds the specified string in the grid from a specific index to start the search and returns it's index value. 
    ' The string is considered as case-insensitive.
    Dim foundedItem As Integer = Me.gridListControl1.FindString("Texas", 5)
    Console.WriteLine("The specified string is found in the index  " & foundedItem)

    FindStringExact(String)

    Finds the first item in the GridListControl that exactly matches the specified string.

    Declaration
    public int FindStringExact(string s)
    Parameters
    Type Name Description
    System.String s

    The text to search for.

    Returns
    Type Description
    System.Int32

    The zero-based index of the first item found; returns langword_csharp_ListBox.NoMatches if no match is found.

    FindStringExact(String, Int32)

    Finds the first item in the GridListControl that exactly matches the specified string. The search starts at a specific starting index.

    Declaration
    public int FindStringExact(string s, int startIndex)
    Parameters
    Type Name Description
    System.String s

    The text to search for.

    System.Int32 startIndex

    The zero-based index of the item before the first item to be searched. Set to negative one (-1) to search from the beginning of the control.

    Returns
    Type Description
    System.Int32

    The zero-based index of the first item found; returns langword_csharp_ListBox.NoMatches if no match is found.

    GetActiveThemeName()

    Gets the active theme of control.

    Declaration
    public string GetActiveThemeName()
    Returns
    Type Description
    System.String

    GetColumnStyle(Int32)

    Provides access to style information for a specified column in the list control.

    Declaration
    public GridStyleInfo GetColumnStyle(int colNum)
    Parameters
    Type Name Description
    System.Int32 colNum

    The zero-based column index.

    Returns
    Type Description
    GridStyleInfo

    The style information for the specified column.

    Remarks

    For GridListControl you need to use this method to access style information because the column styles indexer of the underlying grid control is ignored when style information is collected for cells in the list control.

    Examples

    This example shows how to get the column style of the specified column index.

    void Grid_CellClick(object sender, GridCellClickEventArgs e)
    {
       // Gets the style properties of a given column index and assigns to other GridStyleInfo instance.
       GridStyleInfo myStyle = this.gridListControl1.GetColumnStyle(e.ColIndex);
    }
    Private Sub Grid_CellClick(ByVal sender As Object, ByVal e As GridCellClickEventArgs)
       ' Gets the style properties of a given column index and assigns to other GridStyleInfo instance.
        Dim myStyle As GridStyleInfo = Me.gridListControl1.GetColumnStyle(e.ColIndex)
    End Sub

    GetItemHeight(Int32)

    Returns the height of an item in the GridListControl .

    Declaration
    public int GetItemHeight(int index)
    Parameters
    Type Name Description
    System.Int32 index

    The zero-based index of the item to return the height for.

    Returns
    Type Description
    System.Int32

    The height, in pixels, of the specified item.

    Examples

    This method shows how to get the row height from the specified row index.

    void Grid_CellClick(object sender, GridCellClickEventArgs e)
    {
       int rowHeight = this.gridListControl1.GetItemHeight(e.RowIndex);
       Console.WriteLine("The row height is  " + rowHeight);
    }
    Private Sub Grid_CellClick(ByVal sender As Object, ByVal e As GridCellClickEventArgs)
       Dim rowHeight As Integer = Me.gridListControl1.GetItemHeight(e.RowIndex)
       Console.WriteLine("The row height is  " & rowHeight)
    End Sub

    GetItemRectangle(Int32)

    Returns the bounding rectangle for an item in the GridListControl .

    Declaration
    public Rectangle GetItemRectangle(int index)
    Parameters
    Type Name Description
    System.Int32 index

    The zero-based index of an item whose bounding rectangle you want to return.

    Returns
    Type Description
    System.Drawing.Rectangle

    A System.Drawing.Rectangle that represents the bounding rectangle for the specified item.

    GetItemValue(Object)

    Returns the value for the ValueMember of the specified item.

    Declaration
    public object GetItemValue(object item)
    Parameters
    Type Name Description
    System.Object item

    The row item.

    Returns
    Type Description
    System.Object

    The value of the ValueMember.

    GetRowCount(Object)

    Returns the row count for the specified datasource.

    Declaration
    public virtual int GetRowCount(object dataSource)
    Parameters
    Type Name Description
    System.Object dataSource

    The datasource, typed as System.Object.

    Returns
    Type Description
    System.Int32

    The number of records in the datasource.

    Examples

    This method shows how to get the row count with the specified datasource instance of the grid.

    // Sets the data source to the grid.
    DataTable dataTable = new DataTable();
    this.gridListControl1.DataSource = dataTable;
    // Gets the row count of the associated data source to the grid.
    int rowcount = this.gridListControl1.GetRowCount(dataTable);
    Console.WriteLine("Row count of the associated data source is  " + rowcount);
    ' Sets the data source to the grid.
    Dim dataTable As New DataTable()
    Me.gridListControl1.DataSource = dataTable
    ' Gets the row count of the associated data source to the grid.
    Dim rowcount As Integer = Me.gridListControl1.GetRowCount(dataTable)
    Console.WriteLine("Row count of the associated data source is  " & rowcount)

    GetSelected(Int32)

    Returns a value indicating whether the specified item is selected.

    Declaration
    public bool GetSelected(int index)
    Parameters
    Type Name Description
    System.Int32 index

    The zero-based index of the item that determines whether it is selected.

    Returns
    Type Description
    System.Boolean

    langword_csharp_True If the specified item is currently selected in the GridListControl; otherwise, langword_csharp_False .

    GridCurrentCellActivated(Object, EventArgs)

    Handles the CurrentCellActivated event of the System.EventArgs.

    Declaration
    protected virtual void GridCurrentCellActivated(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.

    GridCurrentCellActivating(Object, GridCurrentCellActivatingEventArgs)

    Handles the CurrentCellActivating event of the GridCurrentCellActivatingEventArgs.

    Declaration
    protected virtual void GridCurrentCellActivating(object sender, GridCurrentCellActivatingEventArgs e)
    Parameters
    Type Name Description
    System.Object sender

    The source of the event.

    GridCurrentCellActivatingEventArgs e

    The GridCurrentCellActivatingEventArgsthat contains event data.

    GridCurrentCellDeactivated(Object, GridCurrentCellDeactivatedEventArgs)

    Handles the CurrentCellDeactivated event of the GridCurrentCellDeactivatedEventArgs.

    Declaration
    protected virtual void GridCurrentCellDeactivated(object sender, GridCurrentCellDeactivatedEventArgs e)
    Parameters
    Type Name Description
    System.Object sender

    The source of the event.

    GridCurrentCellDeactivatedEventArgs e

    The GridCurrentCellDeactivatedEventArgsthat contains event data.

    GridCurrentCellMoving(Object, GridCurrentCellMovingEventArgs)

    Handles the CurrentCellMoving event of the GridCurrentCellMovingEventArgs.

    Declaration
    protected virtual void GridCurrentCellMoving(object sender, GridCurrentCellMovingEventArgs e)
    Parameters
    Type Name Description
    System.Object sender

    The source of the event.

    GridCurrentCellMovingEventArgs e

    The GridCurrentCellMovingEventArgsthat contains event data.

    GridKeyDown(Object, KeyEventArgs)

    Handles the System.Windows.Forms.Control.KeyDown event of the GridModel and moves the current selection when an arrow key is pressed.

    Declaration
    protected virtual void GridKeyDown(object sender, KeyEventArgs e)
    Parameters
    Type Name Description
    System.Object sender

    The source of the event.

    System.Windows.Forms.KeyEventArgs e

    The System.Windows.Forms.KeyEventArgsthat contains event data.

    GridQueryColWidth(Object, GridRowColSizeEventArgs)

    Handles the QueryColWidth event of the Syncfusion.Windows.Forms.Grid and returns the width of individual columns.

    Declaration
    protected virtual void GridQueryColWidth(object sender, GridRowColSizeEventArgs e)
    Parameters
    Type Name Description
    System.Object sender

    The source of the event.

    GridRowColSizeEventArgs e

    TheGridRowColSizeEventArgsthat contains event data.

    GridSelectionChanged(Object, GridSelectionChangedEventArgs)

    Handles the SelectionChanged event of the GridModel and sets SelectedIndex property.

    Declaration
    protected virtual void GridSelectionChanged(object sender, GridSelectionChangedEventArgs e)
    Parameters
    Type Name Description
    System.Object sender

    The source of the event.

    GridSelectionChangedEventArgs e

    TheGridSelectionChangedEventArgsthat contains event data.

    IndexFromPoint(Point)

    Returns the zero-based index of the item at the specified coordinates.

    Declaration
    public int IndexFromPoint(Point p)
    Parameters
    Type Name Description
    System.Drawing.Point p

    A System.Drawing.Point object containing the coordinates used to obtain the item index.

    Returns
    Type Description
    System.Int32

    The zero-based index of the item found at the specified coordinates; returns langword_csharp_ListBox.NoMatches if no match is found.

    IndexFromPoint(Int32, Int32)

    Returns the zero-based index of the item at the specified coordinates.

    Declaration
    public int IndexFromPoint(int x, int y)
    Parameters
    Type Name Description
    System.Int32 x

    The x coordinate of the location to search.

    System.Int32 y

    The y coordinate of the location to search.

    Returns
    Type Description
    System.Int32

    The zero-based index of the item found at the specified coordinates; returns langword_csharp_ListBox.NoMatches if no match is found.

    InitLayout()

    Called after the control has been added to another container.

    Declaration
    protected override void InitLayout()

    OnBackColorChanged(EventArgs)

    Raises the System.Windows.Forms.Control.BackColorChanged event.

    Declaration
    protected override void OnBackColorChanged(EventArgs e)
    Parameters
    Type Name Description
    System.EventArgs e

    The System.EventArgsthat contains event data.

    OnBindingContextChanged(EventArgs)

    This event fired when the binding data source changed.

    Declaration
    protected override void OnBindingContextChanged(EventArgs e)
    Parameters
    Type Name Description
    System.EventArgs e

    The System.EventArgsthat contains event data.

    OnCanApplyThemeChanged(Boolean)

    Helps to override the CanApplyTheme property settings

    Declaration
    public virtual void OnCanApplyThemeChanged(bool canApplyTheme)
    Parameters
    Type Name Description
    System.Boolean canApplyTheme

    OnCanOverrideStyleChanged(Boolean)

    Helps to override the CanOverriderStyle property settings

    Declaration
    public virtual void OnCanOverrideStyleChanged(bool canOverrideStyle)
    Parameters
    Type Name Description
    System.Boolean canOverrideStyle

    OnCausesValidationChanged(EventArgs)

    Gets or sets a value indicating whether the control causes validation to be performed on any controls that require validation when it receives focus.

    Declaration
    protected override void OnCausesValidationChanged(EventArgs e)
    Parameters
    Type Name Description
    System.EventArgs e

    The System.EventArgsthat contains event data.

    OnChangeUICues(UICuesEventArgs)

    Raises the System.Windows.Forms.Control.ChangeUICues event.

    Declaration
    protected override void OnChangeUICues(UICuesEventArgs e)
    Parameters
    Type Name Description
    System.Windows.Forms.UICuesEventArgs e

    The System.Windows.Forms.UICuesEventArgs that contains event data.

    OnControlAdded(ControlEventArgs)

    Raises the System.Windows.Forms.Control.ControlAdded event.

    Declaration
    protected override void OnControlAdded(ControlEventArgs e)
    Parameters
    Type Name Description
    System.Windows.Forms.ControlEventArgs e

    The System.Windows.Forms.ControlEventArgsthat contains event data.

    OnControlGotFocus()

    Raises the System.Windows.Forms.Control.GotFocus event. This method is called when the control or any child control has focus and did not have focus before.

    Declaration
    protected virtual void OnControlGotFocus()
    Remarks

    Inheriting classes should override this method instead of overriding System.Windows.Forms.Control.OnGotFocus(System.EventArgs) because OnControlGotFocus() is also called when child controls get focus and it is not called when focus is moved within child controls of this control.

    OnControlLostFocus()

    Raises the System.Windows.Forms.Control.LostFocus event. This method is called when the control or any child control loses focus and the new focused control is not a child of this control.

    Declaration
    protected virtual void OnControlLostFocus()
    Remarks

    Inheriting classes should override this method instead of overriding System.Windows.Forms.Control.OnLostFocus(System.EventArgs) because OnControlLostFocus() is also called when child controls lose focus and it is not called when focus is moved within child controls of this control.

    OnControlRemoved(ControlEventArgs)

    Raises the System.Windows.Forms.Control.ControlRemoved event.

    Declaration
    protected override void OnControlRemoved(ControlEventArgs e)
    Parameters
    Type Name Description
    System.Windows.Forms.ControlEventArgs e

    The System.Windows.Forms.ControlEventArgsthat contains event data.

    OnDataSourceChanged(EventArgs)

    Overridden. See the System.Windows.Forms.ListControl.DataSourceChanged event.

    Declaration
    protected override void OnDataSourceChanged(EventArgs e)
    Parameters
    Type Name Description
    System.EventArgs e

    A System.EventArgs that contains the event data.

    OnDeactivated(EventArgs)

    Raises the Deactivated event.

    Declaration
    protected virtual void OnDeactivated(EventArgs e)
    Parameters
    Type Name Description
    System.EventArgs e

    An System.EventArgs that contains the event data.

    OnDisplayMemberChanged(EventArgs)

    Overridden. See the System.Windows.Forms.ListControl.DisplayMemberChanged event.

    Declaration
    protected override void OnDisplayMemberChanged(EventArgs e)
    Parameters
    Type Name Description
    System.EventArgs e

    A System.EventArgs that contains the event data.

    OnEnter(EventArgs)

    Raises the System.Windows.Forms.Control.Enter event.

    Declaration
    protected override void OnEnter(EventArgs e)
    Parameters
    Type Name Description
    System.EventArgs e

    The System.EventArgsthat contains event data.

    OnFontChanged(EventArgs)

    Raises the System.Windows.Forms.Control.FontChanged event.

    Declaration
    protected override void OnFontChanged(EventArgs e)
    Parameters
    Type Name Description
    System.EventArgs e

    The System.EventArgsthat contains event data.

    OnGotFocus(EventArgs)

    Raises the System.Windows.Forms.Control.GotFocus event.

    Declaration
    protected override void OnGotFocus(EventArgs e)
    Parameters
    Type Name Description
    System.EventArgs e

    The System.EventArgsthat contains event data.

    OnKeyDown(KeyEventArgs)

    Handles the System.Windows.Forms.Control.KeyDown event of the GridModel and moves the current selection when an arrow key is pressed.

    Declaration
    protected override void OnKeyDown(KeyEventArgs e)
    Parameters
    Type Name Description
    System.Windows.Forms.KeyEventArgs e

    The System.Windows.Forms.KeyEventArgsthat contains event data.

    OnLayout(LayoutEventArgs)

    Raises the System.Windows.Forms.Control.Layout event.

    Declaration
    protected override void OnLayout(LayoutEventArgs e)
    Parameters
    Type Name Description
    System.Windows.Forms.LayoutEventArgs e

    The Systems.Windows.Forms.LayoutEventArgsthat contains event data.

    OnLeave(EventArgs)

    Raises the System.Windows.Forms.Control.Leave event.

    Declaration
    protected override void OnLeave(EventArgs e)
    Parameters
    Type Name Description
    System.EventArgs e

    The System.EventArgsthat contains event data.

    OnLostFocus(EventArgs)

    Raises the System.Windows.Forms.Control.LostFocus event.

    Declaration
    protected override void OnLostFocus(EventArgs e)
    Parameters
    Type Name Description
    System.EventArgs e

    The System.EventArgsthat contains event data.

    OnMultiColumnChanged(EventArgs)

    Raises the MultiColumnChanged event.

    Declaration
    protected virtual void OnMultiColumnChanged(EventArgs e)
    Parameters
    Type Name Description
    System.EventArgs e

    A System.EventArgs that contains the event data.

    OnSelectedIndexChanged(EventArgs)

    Raises the System.Windows.Forms.ListControl.SelectedValueChanged event.

    Declaration
    protected override void OnSelectedIndexChanged(EventArgs e)
    Parameters
    Type Name Description
    System.EventArgs e

    A System.EventArgs that contains the event data.

    OnSelectedValueChanged(EventArgs)

    Overridden to raise the System.Windows.Forms.ListControl.SelectedValueChanged event.

    Declaration
    protected override void OnSelectedValueChanged(EventArgs e)
    Parameters
    Type Name Description
    System.EventArgs e

    A System.EventArgs that contains the event data.

    OnSizeChanged(EventArgs)

    Used to change the behavior of the SizeChanged event

    Declaration
    protected override void OnSizeChanged(EventArgs e)
    Parameters
    Type Name Description
    System.EventArgs e

    The System.EventArgsthat contains event data.

    OnSupportsTransparentBackColorChanged(EventArgs)

    Raises the SupportsTransparentBackColorChanged event.

    Declaration
    protected virtual void OnSupportsTransparentBackColorChanged(EventArgs e)
    Parameters
    Type Name Description
    System.EventArgs e

    An System.EventArgs that contains the event data.

    OnThemeChanged(EventArgs)

    Raises the ThemeChanged event.

    Declaration
    protected virtual void OnThemeChanged(EventArgs e)
    Parameters
    Type Name Description
    System.EventArgs e

    An EventArgs that contains the event data.

    Remarks

    The OnThemeChanged method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.

    Notes to Inheritors: When overriding OnThemeChanged in a derived class, be sure to call the base class's OnThemeChanged method so that registered delegates receive the event.

    OnValidated(EventArgs)

    Raises the System.Windows.Forms.Control.Validated event.

    Declaration
    protected override void OnValidated(EventArgs e)
    Parameters
    Type Name Description
    System.EventArgs e

    The System.EventArgsthat contains event data.

    OnValidating(CancelEventArgs)

    Raises the System.Windows.Forms.Control.Validating event.

    Declaration
    protected override void OnValidating(CancelEventArgs e)
    Parameters
    Type Name Description
    System.ComponentModel.CancelEventArgs e

    The System.ComponentModel.CancelEventArgsthat contains event data.

    OnValidatingLostFocus()

    This method is called if the control's OnControlLostFocus() notification occurs while handling a System.Windows.Forms.Control.Validating event. This typically occurs if a message box is displayed from a System.Windows.Forms.Control.Validating event handler.

    Declaration
    protected virtual void OnValidatingLostFocus()

    OnValueMemberChanged(EventArgs)

    Overridden. See the System.Windows.Forms.ListControl.ValueMemberChanged event.

    Declaration
    protected override void OnValueMemberChanged(EventArgs e)
    Parameters
    Type Name Description
    System.EventArgs e

    A System.EventArgs that contains the event data.

    QueryFocusInside()

    Determines if this control contains focus. Override this method if you want to show drop-down windows and indicate the control has not lost focus when the drop-down is shown.

    Declaration
    public virtual bool QueryFocusInside()
    Returns
    Type Description
    System.Boolean

    True if the control or any child control has focus; False otherwise.

    RaiseThemeChanged(Object, ThemeChangedEventArgs)

    Raises the ThemeNameChanged event when theme name changed.

    Declaration
    protected virtual void RaiseThemeChanged(object sender, ThemeChangedEventArgs args)
    Parameters
    Type Name Description
    System.Object sender

    The sender value.

    ThemeChangedEventArgs args

    A ThemeChangedEventArgs contains the event data.

    RefreshItem(Int32)

    When overridden in a derived class, resynchronizes the data of the object at the specified index with the contents of the datasource.

    Declaration
    protected override void RefreshItem(int index)
    Parameters
    Type Name Description
    System.Int32 index

    The zero-based index of the item whose data to refresh.

    ResetAlphaBlendSelectionColor()

    Resets the AlphaBlendSelectionColor property.

    Declaration
    public void ResetAlphaBlendSelectionColor()

    ResetBackColor()

    Resets the BackColor to its default value.

    Declaration
    public override void ResetBackColor()

    ResetHeaderBackColor()

    Resets the HeaderBackColor property.

    Declaration
    public void ResetHeaderBackColor()

    ResetHeaderTextColor()

    Resets the HeaderTextColor property.

    Declaration
    public void ResetHeaderTextColor()

    ResetProperties()

    Resets the Properties object to its default state.

    Declaration
    public void ResetProperties()

    ResetTableStyle()

    Resets the TableStyle property.

    Declaration
    public void ResetTableStyle()

    SetBoundsCore(Int32, Int32, Int32, Int32, BoundsSpecified)

    Performs the work of setting the specified bounds of this control.

    Declaration
    protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
    Parameters
    Type Name Description
    System.Int32 x

    The new System.Windows.Forms.Control.Left property value of the control.

    System.Int32 y

    The new System.Windows.Forms.Control.Top property value of the control.

    System.Int32 width

    The new System.Windows.Forms.Control.Width property value of the control.

    System.Int32 height

    The new System.Windows.Forms.Control.Height property value of the control.

    System.Windows.Forms.BoundsSpecified specified

    A bitwise combination of the System.Windows.Forms.BoundsSpecified values.

    SetDataBinding(BindingContext, Object, String, String)

    Sets the System.Windows.Forms.ListControl.DataSource, System.Windows.Forms.ListControl.DisplayMember, and System.Windows.Forms.ListControl.ValueMember properties at run-time.

    Declaration
    public void SetDataBinding(BindingContext bindingContext, object dataSource, string displayMember, string valueMember)
    Parameters
    Type Name Description
    System.Windows.Forms.BindingContext bindingContext

    The BindingContext of the parent form.

    System.Object dataSource

    The data source, typed as System.Object, for the GridListControl control.

    System.String displayMember

    A string that specifies the property of the datasource whose contents you want to display.

    System.String valueMember

    A string that specifies the property of the datasource from which to draw the value.

    SetItemCore(Int32, Object)

    Declaration
    protected override void SetItemCore(int index, object value)
    Parameters
    Type Name Description
    System.Int32 index
    System.Object value

    SetItemsCore(IList)

    Clears the contents of the System.Windows.Forms.ListBox and adds the specified items to the control.

    Declaration
    protected override void SetItemsCore(IList items)
    Parameters
    Type Name Description
    System.Collections.IList items

    An array of objects to insert into the control.

    SetSelected(Int32, Boolean)

    Selects or clears the selection for the specified item in a GridListControl .

    Declaration
    public void SetSelected(int index, bool value)
    Parameters
    Type Name Description
    System.Int32 index

    The zero-based index of the item in a GridListControl to select or clear the selection.

    System.Boolean value

    langword_csharp_True to select the specified item; otherwise, langword_csharp_False .

    Examples

    This example shows how to set a row in a selected state with the specified row index.

    // Sets the specific index of the grid to be in the selected state.
    this.gridListControl1.SetSelected(5, true);
    ' Sets the specific index of the grid to be in the selected state.
    Me.gridListControl1.SetSelected(5, True)

    ShouldSerializeAlphaBlendSelectionColor()

    Specifies whether or not to serialize the AlphaBlendSelectionColor in the designer.

    Declaration
    public bool ShouldSerializeAlphaBlendSelectionColor()
    Returns
    Type Description
    System.Boolean

    True to serialize; False otherwise.

    WndProc(ref Message)

    Overridden to process windows messages.

    Declaration
    protected override void WndProc(ref Message m)
    Parameters
    Type Name Description
    System.Windows.Forms.Message m

    The Windows System.Windows.Forms.Message to process.

    Events

    Deactivated

    Occurs when both OnControlLostFocus() and OnLeave(EventArgs) occur.

    Declaration
    public event EventHandler Deactivated
    Event Type
    Type Description
    System.EventHandler

    MultiColumnChanged

    Occurs when the MultiColumn property is changed.

    Declaration
    public event EventHandler MultiColumnChanged
    Event Type
    Type Description
    System.EventHandler

    SupportsTransparentBackColorChanged

    Occurs when the SupportsTransparentBackColor has changed.

    Declaration
    public event EventHandler SupportsTransparentBackColorChanged
    Event Type
    Type Description
    System.EventHandler

    ThemeChanged

    This event will be fired when the ThemesEnabled property is changed.

    Declaration
    public event EventHandler ThemeChanged
    Event Type
    Type Description
    System.EventHandler

    ThemeNameChanged

    Occurs when theme name of the control has changed.

    Declaration
    public event ThemeChangedEventHandler ThemeNameChanged
    Event Type
    Type Description
    ThemeChangedEventHandler

    Explicit Interface Implementations

    IVisualStyle.VisualTheme

    Gets or sets the VisualTheme of the control.

    Declaration
    string IVisualStyle.VisualTheme { get; set; }
    Returns
    Type Description
    System.String

    IThemeProvider.BaseThemeName

    Gets or sets the BaseTheme name of the theme

    Declaration
    string IThemeProvider.BaseThemeName { get; set; }
    Returns
    Type Description
    System.String

    IThemeProvider.ControlName

    Gets the name of the control.

    Declaration
    string IThemeProvider.ControlName { get; }
    Returns
    Type Description
    System.String

    Implements

    IThemedControl
    System.ComponentModel.ISupportInitialize
    IThemeProvider
    IVisualStyle
    Back to top Generated by DocFX
    Copyright © 2001 - 2023 Syncfusion Inc. All Rights Reserved