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

How can we resize DrowDown List width in sfdatagrid GridColumCombobox?

problem.jpg

is it Possible DropDown text wrap?  


3 Replies

SJ Sathiyathanam Jeyakumar Syncfusion Team April 17, 2023 04:19 PM UTC

Hi cho dongsik,

To wrap the text of a ComboBoxItem, you can customize the GridCellComboBoxRenderer and modify the item template of the combobox. Here is a step-by-step guide on how to achieve this:

public sealed partial class MainPage : Page

{

    public MainPage()

    {

        this.InitializeComponent();

        this.dataGrid.CellRenderers.Remove("ComboBox");

        this.dataGrid.CellRenderers.Add("ComboBox", new GridCellComboBoxRendererExt());

    }

}

public class GridCellComboBoxRendererExt : GridCellComboBoxRenderer

{

    public GridCellComboBoxRendererExt() : base()

    {

 

    }

 

    public override void OnInitializeEditElement(DataColumnBase dataColumn, ComboBox uiElement, object dataContext)

    {

        base.OnInitializeEditElement(dataColumn, uiElement, dataContext);

        uiElement.ItemTemplate = Application.Current.Resources["comboboxStyle"] as DataTemplate;

       

    }

}


App.xaml

<Application.Resources>

    <DataTemplate x:Key="comboboxStyle">

        <TextBlock Text="{Binding}" Width="200" TextWrapping="Wrap" />

    </DataTemplate>

</Application.Resources>


Before: