Grid in Rectangle tool

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Amol
Advanced
Posts: 176
Joined: Mon May 29, 2006 12:00 am

Grid in Rectangle tool

Post by Amol » Tue Apr 29, 2014 2:07 pm

Hi Steema Support,
Is it possible to add data grid view (dot net control) or any table layout control, we can add in teechart Rectangle tool as shown in fig. below
Untitled.jpg
Untitled.jpg (40.42 KiB) Viewed 5146 times
It will so helpful for us if you please provide any alternative solution.

Thanks in advance.


Thanks and Regards
Planoresearch

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Grid in Rectangle tool

Post by Christopher » Fri May 02, 2014 8:55 am

Amol,

Apologies in the delay in replying. Yesterday was a holiday here.

Yes, you could think of deriving your own class, e.g.

Code: Select all

  public class MyRectangleTool : RectangleTool
  {
    public MyRectangleTool() : this((Chart)null)
    {
    }

    public MyRectangleTool(Chart c)
      : base(c)
    {
      DataGridView = new DataGridView();
      IChart parent = c.Parent;
      if (parent != null)
      {
        Control control = parent.GetControl();
        control.Controls.Add(DataGridView);
      }
    }

    public DataGridView DataGridView
    {
      get;
      set;
    }

    protected override void ChartEvent(EventArgs e)
    {
      base.ChartEvent(e);
      if (e is BeforeDrawEventArgs)
      {
        Rectangle newBounds = Bounds;
        newBounds.Inflate(-10, -10);
        DataGridView.Bounds = newBounds;
      }
    }

    protected override void OnResizing(EventArgs e)
    {
      base.OnResizing(e);
      Rectangle newBounds = Bounds;
      newBounds.Inflate(-10, -10);
      DataGridView.Bounds = newBounds;
    }
  }
and then using it in your chart, e.g.

Code: Select all

    private void InitializeChart()
    {
      tChart1.Aspect.View3D = false;
      Line line = new Line(tChart1.Chart);
      line.FillSampleValues();

      MyRectangleTool tool = new MyRectangleTool(tChart1.Chart);
      tool.Shape.Transparency = 0;
      tool.Width = 100;
      tool.Left = 100;
      tool.Top = 100;
    }
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Post Reply