Page 1 of 1

Grid in Rectangle tool

Posted: Tue Apr 29, 2014 2:07 pm
by 9641422
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 5098 times
It will so helpful for us if you please provide any alternative solution.

Thanks in advance.


Thanks and Regards
Planoresearch

Re: Grid in Rectangle tool

Posted: Fri May 02, 2014 8:55 am
by Christopher
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;
    }