Category / Section
How to disable editing for a specific cell in UWP Gantt?
1 min read
Description:
This article describes how to disable editing for a specific cell in Gantt grid.
Solution:
This requirement can be achieved by setting IsCancel event argument as True in the BeginCellEdit event based on the necessary condition.
The following code sample illustrates the usage of BeginCellEdit event to disable the editing task’s Name which having ID as “3”.
[XAML] <gantt:SfGantt x:Name="Gantt" AllowEditing="True" ItemsSource="{Binding TaskCollection}" BeginCellEdit="SfGantt_OnBeginCellEdit" > </gantt:SfGantt>
[C#] /// <summary> /// Event invoked when cell edit begins in the Gantt grid. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SfGantt_OnBeginCellEdit(object sender, BeginCellEditEventArgs e) { //Condition to disable the editing of the Name’s cell for the task with ID as 3. if (e.Item is TaskDetail && (e.Item as TaskDetail).ID.Equals("3") && e.MappingName.Equals("Name")) { e.IsCancel = true; } }
Please find the required sample from the link.