Displaying TChart on a GDI+ surface in design mode

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
JamesThomas
Newbie
Newbie
Posts: 6
Joined: Fri Dec 02, 2005 12:00 am
Contact:

Displaying TChart on a GDI+ surface in design mode

Post by JamesThomas » Thu May 25, 2006 3:55 pm

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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri May 26, 2006 10:20 am

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

JamesThomas
Newbie
Newbie
Posts: 6
Joined: Fri Dec 02, 2005 12:00 am
Contact:

Displaying TChart on a GDI+ surface in design mode

Post by JamesThomas » Wed May 31, 2006 9:51 am

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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed May 31, 2006 11:28 am

Hi Martin,

Have you tried using tChart1.Draw(Graphics g)? Do you have any problem using your code with this method?
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

JamesThomas
Newbie
Newbie
Posts: 6
Joined: Fri Dec 02, 2005 12:00 am
Contact:

Displaying TChart on a GDI+ surface in design mode

Post by JamesThomas » Wed May 31, 2006 1:40 pm

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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed May 31, 2006 1:48 pm

Hi Martin,

Try using:

Code: Select all

TChart.Left = rect.X;
TChart.Top = rect.Y;
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

JamesThomas
Newbie
Newbie
Posts: 6
Joined: Fri Dec 02, 2005 12:00 am
Contact:

Displaying TChart on a GDI+ surface in design mode

Post by JamesThomas » Wed May 31, 2006 1:55 pm

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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Jun 01, 2006 10:39 am

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

JamesThomas
Newbie
Newbie
Posts: 6
Joined: Fri Dec 02, 2005 12:00 am
Contact:

Displaying TChart on a GDI+ surface in design mode

Post by JamesThomas » Thu Jun 01, 2006 3:48 pm

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

Post Reply