New to Telerik UI for WinForms? Download free 30-day trial

Adding new items

RadGanttView uses its data source to create a hierarchical data structure. To be able to do that the gantt view must be able to identify each item by a unique id. When new items are added in bound mode you are responsible for providing ids for the items which will be stored in the data source. This is needed so the gantt view can maintain the hierarchical structure of the items without any distortions. If you fail to provide an id you will get an exception.

Here is an example of how to provide ids using the ItemChildIdNeeded event. The event is fired every time a new item is created and is about to be added to the data source.

int integerIdCounter = 100;
private void radGanttView1_ItemChildIdNeeded(object sender, GanttViewItemChildIdNeededEventArgs e)
{
    e.ChildId = this.integerIdCounter++;
}

Dim integerIdCounter As Integer = 100
Private Sub radGanttView1_ItemChildIdNeeded(sender As Object, e As GanttViewItemChildIdNeededEventArgs)
    Me.integerIdCounter += 1
    e.ChildId = Me.integerIdCounter
End Sub

See Also

In this article