Hi,
I have other controls on my form under my chart, such as textboxes.
When the user prints, I want to basically print all the controls on the form, not just the chart.
Is there an easy way to integrate this functionality into TeeChart without having to draw each control individually, including the chart, on the form.
Thanks.
Printing other controls with TeeChart
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Agrilink,
Could you please give us more information about that? What do you exactly mean saying "When the user prints"? Does it use TeeChart's print preview or other printing facilities?
Thanks in advance.
Could you please give us more information about that? What do you exactly mean saying "When the user prints"? Does it use TeeChart's print preview or other printing facilities?
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 |
Instructions - How to post in this forum |
Hi Narcis,
When using TeeChart's "Print" method, eg. "tChart1.Printer.Print(true);" - this only prints the chart as specified in the help. Similarly, the "Preview" method only shows the chart.
On my form, I have other controls such as TextBoxes and CheckBoxes in a panel docked to the bottom of the form and the chart filling the rest of the form.
The TextBoxes display the series values at the cursor position on the X-Axis, so when ever the cursor is moved the values in the TextBoxes are updated.
What I want to do is show the entire form, ie. the chart plus the controls beneath the chart, when doing a Print Preview and Printing the form.
So I've resorted to using .NET's "PrintPreviewDialog" and "PrintDocument" controls.
I can individually draw each control eg:
private void DrawForm(Graphics g)
{
foreach (Control c in this.panel1.Controls)
{
string sType = c.GetType().ToString().Substring(c.GetType().ToString().LastIndexOf(".") + 1);
switch (sType)
{
case "CheckBox":
CheckBox chk = (CheckBox)c;
// Use the DrawCheckBox command to draw a checkbox and pass the button state to paint it checked or unchecked
if (chk.Checked)
ControlPaint.DrawCheckBox(g, chk.Left, chk.Top, chk.Height / 2, chk.Height / 2, ButtonState.Checked);
else
ControlPaint.DrawCheckBox(g, chk.Left, chk.Top, chk.Height / 2, chk.Height / 2, ButtonState.Normal);
// Don't forget the checkbox text
g.DrawString(chk.Text, chk.Font, new SolidBrush(chk.ForeColor), chk.Right + chk.Height - g.MeasureString(chk.Text, chk.Font).Width,
chk.Top, new StringFormat());
break;
case "TextBox":
TextBox txt = (TextBox)c;
// Draw a text box by drawing a pushed in button and filling the rectangle with the background color and the text
// of the TextBox control
// First the sunken border
ControlPaint.DrawButton(g, txt.Left, txt.Top, txt.Width, txt.Height, ButtonState.Pushed);
// Then fill it with the background of the textbox
g.FillRectangle(new SolidBrush(txt.BackColor), txt.Left + 1, txt.Top + 1, txt.Width + 2, txt.Height - 2);
// Finally draw the string inside
g.DrawString(txt.Text, txt.Font, new SolidBrush(txt.ForeColor), txt.Left + 2,
txt.Top + txt.Height / 2 - g.MeasureString(txt.Text, txt.Font).Height / 2, new StringFormat());
break;
}
}
}
However, how would I do the same for a TeeChart?
If there's no easier way, I'll create an image such as a bitmap, then use the "DrawImage" method of the Graphics class, before using the above code to draw the rest of the controls on the form.
So to me it seems I can't use TeeChart's printing facilities?
Thanks for your help.
When using TeeChart's "Print" method, eg. "tChart1.Printer.Print(true);" - this only prints the chart as specified in the help. Similarly, the "Preview" method only shows the chart.
On my form, I have other controls such as TextBoxes and CheckBoxes in a panel docked to the bottom of the form and the chart filling the rest of the form.
The TextBoxes display the series values at the cursor position on the X-Axis, so when ever the cursor is moved the values in the TextBoxes are updated.
What I want to do is show the entire form, ie. the chart plus the controls beneath the chart, when doing a Print Preview and Printing the form.
So I've resorted to using .NET's "PrintPreviewDialog" and "PrintDocument" controls.
I can individually draw each control eg:
private void DrawForm(Graphics g)
{
foreach (Control c in this.panel1.Controls)
{
string sType = c.GetType().ToString().Substring(c.GetType().ToString().LastIndexOf(".") + 1);
switch (sType)
{
case "CheckBox":
CheckBox chk = (CheckBox)c;
// Use the DrawCheckBox command to draw a checkbox and pass the button state to paint it checked or unchecked
if (chk.Checked)
ControlPaint.DrawCheckBox(g, chk.Left, chk.Top, chk.Height / 2, chk.Height / 2, ButtonState.Checked);
else
ControlPaint.DrawCheckBox(g, chk.Left, chk.Top, chk.Height / 2, chk.Height / 2, ButtonState.Normal);
// Don't forget the checkbox text
g.DrawString(chk.Text, chk.Font, new SolidBrush(chk.ForeColor), chk.Right + chk.Height - g.MeasureString(chk.Text, chk.Font).Width,
chk.Top, new StringFormat());
break;
case "TextBox":
TextBox txt = (TextBox)c;
// Draw a text box by drawing a pushed in button and filling the rectangle with the background color and the text
// of the TextBox control
// First the sunken border
ControlPaint.DrawButton(g, txt.Left, txt.Top, txt.Width, txt.Height, ButtonState.Pushed);
// Then fill it with the background of the textbox
g.FillRectangle(new SolidBrush(txt.BackColor), txt.Left + 1, txt.Top + 1, txt.Width + 2, txt.Height - 2);
// Finally draw the string inside
g.DrawString(txt.Text, txt.Font, new SolidBrush(txt.ForeColor), txt.Left + 2,
txt.Top + txt.Height / 2 - g.MeasureString(txt.Text, txt.Font).Height / 2, new StringFormat());
break;
}
}
}
However, how would I do the same for a TeeChart?
If there's no easier way, I'll create an image such as a bitmap, then use the "DrawImage" method of the Graphics class, before using the above code to draw the rest of the controls on the form.
So to me it seems I can't use TeeChart's printing facilities?
Thanks for your help.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Agrilink,
Thanks for the reply. Then you could try using tChart1.Draw(g) which will draw the chart into g.
Thanks for the reply. Then you could try using tChart1.Draw(g) which will draw the chart into g.
Best Regards,
Narcís Calvet / 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 |
Hi Narcis,
That work's equally as well, though using:
Bitmap image = this.tChart1.Chart.Bitmap(width, height);
g.DrawImage(image, xpos, ypos);
I can specify the position to print the chart.
Using tChart1.Draw(g) will only draw the chart at 0,0 coordinates?
Anyway, using either method, a border is drawn along the bottom and up the right side of the chart, even if the background color of the chart is changed from the default.
Is there a way to remove these lines?
Thanks.
That work's equally as well, though using:
Bitmap image = this.tChart1.Chart.Bitmap(width, height);
g.DrawImage(image, xpos, ypos);
I can specify the position to print the chart.
Using tChart1.Draw(g) will only draw the chart at 0,0 coordinates?
Anyway, using either method, a border is drawn along the bottom and up the right side of the chart, even if the background color of the chart is changed from the default.
Is there a way to remove these lines?
Thanks.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Agrilink,
You should add the code below to make inner and outer bevels not visible.
You should add the code below to make inner and outer bevels not visible.
Code: Select all
tChart1.Panel.Bevel.Inner = Steema.TeeChart.Drawing.BevelStyles.None;
tChart1.Panel.Bevel.Outer = Steema.TeeChart.Drawing.BevelStyles.None;
Best Regards,
Narcís Calvet / 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 |