We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Show DropDown arrow in GridComboBoxColumn

I found two articles about showing dropdown arrow in GridComboBoxColumn for WPF and WindowsPhone platforms. Is there any way to do the same thing for SfDataGrid in Winform? My requirement would be same as what's been written in the articles. 

Show DropDown arrow in WPF DataGrid GridComboBoxColumn | Syncfusion KB

How to differentiate the GridCombobox column from other columns in non-editable display mode? | Windows Phone - SfDataGrid (syncfusion.com)


1 Reply

DM Dhanasekar Mohanraj Syncfusion Team November 10, 2022 09:00 AM

This requirement can be achieved by showing the drop-down arrow in the display mode by creating a custom renderer for the combo box column shown below,

public Form1()

{

    InitializeComponent();

    this.sfDataGrid1.CellRenderers["ComboBox"] = new CustomComboBoxCellRenderer();

}

 

public class CustomComboBoxCellRenderer : GridComboBoxCellRenderer

{

    protected override void OnRender(Graphics paint, Rectangle cellRect, string cellValue, CellStyleInfo style, DataColumnBase column, Syncfusion.WinForms.GridCommon.ScrollAxis.RowColumnIndex rowColumnIndex)

    {

        base.OnRender(paint, cellRect, cellValue, style, column, rowColumnIndex);

        var dropDownbuttonRect = new Rectangle(cellRect.X + cellRect.Width - 17, cellRect.Y + (cellRect.Height / 2), 8, 4);

        paint.DrawLine(new Pen(Color.Gray), dropDownbuttonRect.X, dropDownbuttonRect.Y, dropDownbuttonRect.X + (dropDownbuttonRect.Width / 2), dropDownbuttonRect.Y + dropDownbuttonRect.Height);

        paint.DrawLine(new Pen(Color.Gray), dropDownbuttonRect.X + dropDownbuttonRect.Width, dropDownbuttonRect.Y, dropDownbuttonRect.X + (dropDownbuttonRect.Width / 2), dropDownbuttonRect.Y + dropDownbuttonRect.Height);

    }

}


We have already published the Knowledge base for your requirement. For more information related to showing the dropdown arrow in GridComboBoxColumn, please refer to the below knowledge base documentation link,


KB Link:  https://www.syncfusion.com/kb/10013/how-to-differentiate-combobox-column-from-other-columns-in-non-editable-display-mode-in


If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.


Loader.
Live Chat Icon For mobile
Up arrow icon