How to change width and height of spceific objects in RadGanttView

1 Answer 39 Views
GanttView
João
Top achievements
Rank 1
Iron
Iron
Iron
João asked on 11 Jun 2024, 11:57 AM

Hellow!

How can i change the following properties in the object "RadGanttView" (check image for color usage)

  • Height (RED)
  • Width (BLUE)

1 Answer, 1 is accepted

Sort by
1
Nadya | Tech Support Engineer
Telerik team
answered on 14 Jun 2024, 10:49 AM

Hello, João,

Thank you for writing.  

You can control what time part exactly a certain element represents. This is controlled by the GanttViewElement.GraphicalViewElement.OnePixelTime property. Thus, you can shrink or enlarge the time parts: 

this.radGanttView1.GanttViewElement.GraphicalViewElement.OnePixelTime = new TimeSpan(0, 0, 10, 0, 0);

Feel free to adjust the OnePixelTime property according to your needs. More information about TimeLine views is available here: Timeline Views - WinForms GanttView Control - Telerik UI for WinForms

As for increasing the height of GanttViewTimelineItemTopElement I would like to note that this is not an easy task. You may need to create a custom GanttViewTimelineItemElement and override its MeasureOverride method. Keep in mind that RadGanttView has a complex structure, and if you decide to measure and arrange inner elements you may need to arrange the bottom element as well. 

The GanttViewTimelineItemElement can be replaced in TimelineItemElementCreating event. I prepared a sample demonstration for your reference. Feel free to modify it according to your needs:

private void RadGanttView1_TimelineItemElementCreating(object sender, GanttViewTimelineItemElementCreatingEventArgs e)
{
    e.ItemElement = new CustomGanttViewTimelineItemElement(e.Item, (sender as RadGanttViewElement).GraphicalViewElement);
}
public class CustomGanttViewTimelineItemElement : GanttViewTimelineItemElement
{
    public CustomGanttViewTimelineItemElement(GanttViewTimelineDataItem data, GanttViewGraphicalViewElement graphicalViewElement) : base(data, graphicalViewElement)
    {
    }

    protected override SizeF MeasureOverride(SizeF availableSize)
    {
        this.TopElement.StretchVertically = true;
        this.BottomElement.StretchVertically = false;
        RectangleF clientRect = this.GetClientRectangle(availableSize);
        float width = this.Data.Width - this.GraphicalViewElement.TimelineContainer.ItemSpacing + availableSize.Width - clientRect.Width;

        this.TopElement.Measure(new SizeF(width, clientRect.Height / 2f));
        this.BottomElement.Measure(new SizeF(width, clientRect.Height / 2f));

        return new SizeF(width, this.TopElement.DesiredSize.Height + 20 + this.BottomElement.DesiredSize.Height);
    }

I hope this information is useful. If you have any other questions let me know. 

Regards,
Nadya | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
GanttView
Asked by
João
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Nadya | Tech Support Engineer
Telerik team
Share this question
or