Page 1 of 1

Displaying TChart on a GDI+ surface in design mode

Posted: Thu May 25, 2006 3:55 pm
by 9639355
Hi,

I am trying to add a TChart to a GDI+ surface but have it appear in design mode. How can I achieve this?

I have a System.Drawing.Graphics object for the surface and I can do the following:

Bitmap image = TChart.Chart.Bitmap((int) rect.Width, (int) rect.Height);
g.DrawImage(image, (int)rect.X, (int)rect.Y);

But this displays the TChart in runtime mode.

Thanks,
James

Posted: Fri May 26, 2006 10:20 am
by narcis
Hi James,

We don't understand what are you exactly trying to do, could you please give us more information and, if possible, send us an example project or some code snippet?

Thanks in advance.

Displaying TChart on a GDI+ surface in design mode

Posted: Wed May 31, 2006 9:51 am
by 9639355
Hi Narcís,

We are building a report designer. Users will be allowed to add a TChart to their reports. The reports themselves are displayed on the screen on a GDI+ drawing surface, not on a Windows Form. This is because we need to allow them to zoom and do various actions that are not possible on a Windows Form.

I see that the majority of users will be using TChart on Forms so will not encounter this problem.

I have a System.Drawing.Graphics object for the report and I need to add (using only code) a TChart to this surface. As I mentioned above I can do this with the lines:

TChart = new Steema.TeeChart.TChart();

Rectangle rect = GetPaintRectangle(); // local function which returns the rectangle to insert the chart

Bitmap image = TChart.Chart.Bitmap( rect.Width, rect.Height);
g.DrawImage(image, rect.X, rect.Y);

This shows the TChart on the GDI+ surface, but it is in runtime mode. This is fine for when we want to show the report in Preview mode, but we also want to be able to display the TChart in design mode. Is this possible without using Forms – using only our GDI+ drawing surface?

Thanks,
Martin

Posted: Wed May 31, 2006 11:28 am
by narcis
Hi Martin,

Have you tried using tChart1.Draw(Graphics g)? Do you have any problem using your code with this method?

Displaying TChart on a GDI+ surface in design mode

Posted: Wed May 31, 2006 1:40 pm
by 9639355
Narcís,

The problem with that approach is that I cannot seem to place the Chart where I would like on the GDI surface. It always appears at (0,0). I have tried using the Size and Location properties. Size works but Location doesn't.

// Below displays chart with correct size but always at 0,0
TChart.Size = new Size(rect.Width, rect.Height);
TChart.Location = new Point(rect.X, rect.Y);
TChart.Draw(g);

Martin

Posted: Wed May 31, 2006 1:48 pm
by narcis
Hi Martin,

Try using:

Code: Select all

TChart.Left = rect.X;
TChart.Top = rect.Y;

Displaying TChart on a GDI+ surface in design mode

Posted: Wed May 31, 2006 1:55 pm
by 9639355
Narcís,

Still appearing at 0,0

:?

As an experiment I have another project which is a Windows form and these properties do work. It appears to be to do with the fact this is a GDI+ surface?

Martin

Posted: Thu Jun 01, 2006 10:39 am
by narcis
Hi Martin,

Could you please send us an example we can run "as-is" to reproduce the problem here?

You can post your files at news://www.steema.net/steema.public.attachments newsgroup.

Thanks in advance.

Displaying TChart on a GDI+ surface in design mode

Posted: Thu Jun 01, 2006 3:48 pm
by 9639355
Narcís,

Most of the code is copyrighted so I can't post as is, I will see if I can put something similar together for you instead though.

Thanks,
Martin