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:


After:


Let us know if you need any further assistance on this.


Regards,

Sathiyathanam


Attachment: App1_b4404a45.zip


CD cho dongsik April 18, 2023 01:05 AM UTC

Thanks



SJ Sathiyathanam Jeyakumar Syncfusion Team April 18, 2023 05:16 AM UTC

cho dongsik

We are glad that the provided response meets your requirement. Please let us know if you need further assistance. As always, we are happy to help you out. 


Loader.
Live Chat Icon For mobile