Programmatically Export GanttView to File

3 posts, 0 answers
  1. Yemo
    Yemo avatar
    13 posts
    Member since:
    Sep 2006

    Posted 17 Mar Link to this post


    Please advise whteher there is an available code sample on how to use the following specified method in winforms

    IImageExporter..::..ExportToImage Method

    or any alternative routine to achieve the same desired effect.

    Many thanks

  2. Dimitar
    Dimitar avatar
    1871 posts

    Posted 21 Mar Link to this post

    Hello Yemi,

    Thank you for writing.

    We have internal methods that can export the Gantt to an image, they are used for printing. Here is how you can use them to create an image:
    class MyGantt : RadGanttView
        public void Export(string path)
            GanttViewTraverser traverser = new GanttViewTraverser(this.GanttViewElement);
            traverser.TraverseAllItems = true;
            List<GanttViewDataItem> flatItemsCollection = new List<GanttViewDataItem>();
            while (traverser.MoveNext())
            float height = flatItemsCollection.Count * this.ItemHeight + this.HeaderHeight;
            float width = (float)((this.GanttViewElement.GraphicalViewElement.TimelineBehavior.AdjustedTimelineEnd.AddDays(1) - this.GanttViewElement.GraphicalViewElement.TimelineBehavior.AdjustedTimelineStart).TotalSeconds /
            Bitmap bmp = new Bitmap((int)width,(int)height);
            int columnsWidth = 0;
            foreach (GanttViewTextViewColumn col in this.Columns)
                if (col.Visible)
                    columnsWidth += col.Width;
            this.drawArea = new RectangleF(0, 0, columnsWidth, 100);
            using (Graphics grp = Graphics.FromImage(bmp))
                grp.FillRectangle( Brushes.White, 0, 0, bmp.Width, bmp.Height);

    I hope this will be useful. Let me know if you have additional questions.

    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Yemo
    Yemo avatar
    13 posts
    Member since:
    Sep 2006

    Posted 22 Mar in reply to Dimitar Link to this post

    Ok thanks. Worked for me.

    I guess you guys have your reasons for making the methods internal.

Back to Top