Page 1 of 1
Grid in Rectangle tool
Posted: Thu May 15, 2014 2:12 pm
by 9641422
Hi Steema Support,
Many thanks for your reply and given examples but it is not same thing for what we are looking.
We cannot drag Rectangle Tool smoothly if we drag through Datagridview and show flickering. And when we export picture of teechart then it does not export Datagridview (Only show Rectangle Tool)
It will be very helpful for us, if you please provide any alternative solution as soon as possible.
Thanks in advance.
Thanks and Regards
Planoresearch
Re: Grid in Rectangle tool
Posted: Fri May 16, 2014 9:42 am
by Christopher
Hello!
The only other solution I can think of is you manually draw your own grid within a custom RectangleTool, e.g.
Code: Select all
public class MyRectangleTool : RectangleTool
{
public MyRectangleTool()
: this((Chart)null)
{
}
public MyRectangleTool(Chart c)
: base(c)
{
}
protected override void ChartEvent(EventArgs e)
{
base.ChartEvent(e);
if (e is AfterDrawEventArgs)
{
DrawGrid(Chart.Graphics3D, Bounds);
}
}
const double numCols = 3.0;
const double numRows = 3.0;
private void DrawGrid(Graphics3D g, Rectangle rect)
{
int horizIncrement = Utils.Round((double)rect.Width / numCols);
int vertIncrement = Utils.Round((double)rect.Height / numRows);
for (int i = rect.Left; i < rect.Right; i += horizIncrement)
{
g.VerticalLine(i, rect.Top, rect.Bottom - 1);
}
for (int i = rect.Top; i < rect.Bottom; i += vertIncrement)
{
g.HorizontalLine(rect.Left, rect.Right - 1, i);
}
}
}
again, using it like this:
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;
}
Re: Grid in Rectangle tool
Posted: Mon Nov 24, 2014 1:23 pm
by 9641422
Hi Steema Support,
Can you write data in each row? We are using this g.TextOut(i, rect.Top, rect.Bottom - 1, "HI"); to write but this method write only one row not all. Image is attached
for (int i = rect.Left; i < rect.Right; i += horizIncrement)
{
g.VerticalLine(i, rect.Top, rect.Bottom - 1);
g.TextOut(i, rect.Top, rect.Bottom - 1, "HI");
}
- Image
- img.png (107.66 KiB) Viewed 10789 times
Thanks in advance.
Thanks & Regards
PlanoResearch
Re: Grid in Rectangle tool
Posted: Tue Nov 25, 2014 9:59 am
by Christopher
Amol wrote:Can you write data in each row?
This is a basic programming task which is not TeeChart API specific. You could do something like this:
Code: Select all
protected override void ChartEvent(EventArgs e)
{
base.ChartEvent(e);
if (e is AfterDrawEventArgs)
{
DrawGrid(Chart.Graphics3D, Bounds);
DrawCells(Chart.Graphics3D, Bounds);
}
}
private void DrawCells(Graphics3D g, Rectangle rect)
{
int horizIncrement = Utils.Round((double)rect.Width / numCols);
int vertIncrement = Utils.Round((double)rect.Height / numRows);
for (int i = rect.Left; i < rect.Right - 1; i += horizIncrement)
{
for (int j = rect.Top; j < rect.Bottom; j += vertIncrement)
{
g.TextOut(i, j, "BYE");
}
}
}
Re: Grid in Rectangle tool
Posted: Tue Nov 25, 2014 10:55 am
by 9641422
Hi Steema,
Thanks for your reply, We want to set the column size according to the text written in that column. Suppose first column have text of 100 character and second column column contains 10 character the column size should be accordingly. and can we wrap the text written in it.We are waiting for your response.
Thanks
Plano
Re: Grid in Rectangle tool
Posted: Tue Nov 25, 2014 11:06 am
by Christopher
Amol wrote:
Thanks for your reply, We want to set the column size according to the text written in that column. Suppose first column have text of 100 character and second column column contains 10 character the column size should be accordingly. We are waiting for your response.
You can use the Graphics3D.TextWidth() method to measure the length of strings, e.g.