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

Binding to database

RadGanttView supports binding to Database data. Levels are created using the Parent and Child members' values. You can read more on the data binding properties of RadGanttView in the binding basics article.

  1. In a new Windows project drop a RadGanttView control on the form.

  2. In the DataSource property drop down in the Properties window of from the Smart Tag of the control select the Add Project Data Source link.

  3. In the Choose a Data Source Type page select the Database icon, then click the Next button.

    WinForms RadGanttView Data Source Configuration Wizard

  4. In the Choose Your Data Connection page of the wizard click the New Connection button.

  5. In the Add Connection dialog click Change, select "Microsoft Access Database File" and click OK. In the Database file name entry click Browse and locate the WeddingPlanner.mdb file. Click OK. When prompted if you would like to copy the local data file to your project click Yes.

    You can download the mdb file from here: WeddingPlanner.mdb

    WinForms RadGanttView Add Connection

  6. In the Choose Your Database Objects page of the wizard check the "Tasks" and "Links" tables checkboxes. Click Finish.

    WinForms RadGanttView Selected Tables

  7. Set the DataSource property first to Tasks, then to Links datatable. This will create the necessary data-binding components in the component tray - a DataSet, BindingSources and TableAdapters. The DataSet is the container for the data, the TableAdapters are used to fill the DataSet.

  8. In the Smart Tag or in the properties window set the member properties in the following way.

    WinForms RadGanttView Smart Tag

  9. Once the binding is completed, you can open the Edit Columns option from the Smart Tag, where you can add three columns. Make sure to set their FieldName's to the respective fields - Title, Start and End.

    WinForms RadGanttView Edit Columns

  10. Finally add this code to the form load event handler to specify the timeline range:

this.radGanttView1.GanttViewElement.GraphicalViewElement.TimelineStart = new DateTime(2006, 8, 2);
this.radGanttView1.GanttViewElement.GraphicalViewElement.TimelineEnd = new DateTime(2007, 4, 2);

Me.radGanttView1.GanttViewElement.GraphicalViewElement.TimelineStart = New DateTime(2006, 8, 2)
Me.radGanttView1.GanttViewElement.GraphicalViewElement.TimelineEnd = New DateTime(2007, 4, 2)

WinForms RadGanttView Bound Mode

See Also

In this article