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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Gantt Control - Cell with Combox Binding

Thread ID:

Created:

Updated:

Platform:

Replies:

149927 Dec 14,2019 09:58 PM UTC Dec 16,2019 09:53 AM UTC WPF 1
loading
Tags: GanttControl
Ondrej
Asked On December 14, 2019 09:58 PM UTC

Hi,
is there any way how to binding ViewModel ItemsSource to ComboBox inside Gantt? I have custom column with CellType ComboBox.

I didn't found any similar example. Thanks

Ondrej Rada

Rachel A [Syncfusion]
Replied On December 16, 2019 09:53 AM UTC

Hi Ondrej, 
Greetings from Syncfusion. 
We have prepared sample for having combo box column, download the sample from the below link. 
Also, find the code example below to implement the same. 
[C#] 
  private void Gantt_OnLoaded(object sender, RoutedEventArgs e) 
        { 
            ObservableCollection<double> RiskPercent = new ObservableCollection<double>(); 
            RiskPercent.Add(10); 
            RiskPercent.Add(20); 
            RiskPercent.Add(30); 
            RiskPercent.Add(40); 
            RiskPercent.Add(50); 
            RiskPercent.Add(60); 
            RiskPercent.Add(70); 
            RiskPercent.Add(80); 
            RiskPercent.Add(90); 
 
            // Creating a new custom column with combo box 
            GridTreeColumn riskColumn = new GridTreeColumn 
                                           { 
                                               MappingName = "RiskPercentage", 
                                               HeaderText = "Risk", 
                                               Width = 120, 
                                               StyleInfo = new GridStyleInfo 
                                                               { 
                                                                   CellType = "ComboBox", 
                                                                   ItemsSource = RiskPercent, 
                                                                   HorizontalAlignment = 
                                                                       HorizontalAlignment 
                                                                           .Center, 
                                                                   VerticalAlignment = 
                                                                       VerticalAlignment 
                                                                           .Center 
                                               } 
                                           }; 
 
            this.Gantt.GanttGrid.InternalGrid.DropDownSelectionChanged += InternalGrid_DropDownSelectionChanged; 
             
            this.Gantt.GanttGrid.Columns.Insert(2, riskColumn); 
        } 
 
        private void InternalGrid_DropDownSelectionChanged(object sender, GridCellComboValueChangedEventArgs args) 
        { 
            GridTreeNode node = this.Gantt.GanttGrid.InternalGrid.GetNodeAtRowIndex(args.CellRowColumnIndex.RowIndex); 
            int risk; 
            if (node != null && node.Item != null) 
            { 
                if (int.TryParse(args.SelectedItem as string, out risk)) 
                { 
                    (node.Item as Task).RiskPercentage = risk; 
                } 
            } 
        } 
 
Thanks, 
Rachel. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon