Hi asupriya,
We will get back to you regarding the printing issue.
This works fine using this code:
Code: Select all
Private WithEvents button1 As Button
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Width = 800
Me.Height = 600
InitializeChart()
button1 = New Button()
Me.Controls.Add(button1)
button1.Location = New Point(Me.Width / 2, Me.Height - button1.Height * 3)
button1.Text = "Print"
button1.AutoSize = True
AddHandler button1.Click, AddressOf button1_Click
End Sub
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim tChart As Steema.TeeChart.TChart = CType(Controls(0), Steema.TeeChart.TChart)
tChart.Printer.BeginPrint()
Dim i As Integer
For i = 1 To 4
tChart.Printer.Print(CType(Controls(i), Steema.TeeChart.TChart).Chart, rects(i))
Next
tChart.Printer.Print(rects(0))
tChart.Printer.EndPrint()
End Sub
Dim rects() As Rectangle
Private Sub InitializeChart()
rects = New Rectangle(5) {}
Dim rect As Rectangle
Dim i As Integer
For i = 0 To 4
Dim tChart1 As Steema.TeeChart.TChart = New Steema.TeeChart.TChart()
Me.Controls.Add(tChart1)
rect = New Rectangle(New Point(0, 100 * i), New Size(Me.Width, 100))
rects(i) = rect
tChart1.Location = rect.Location
tChart1.Width = rect.Width
tChart1.Height = rect.Height
Dim fastLine1 As Steema.TeeChart.Styles.FastLine = New Steema.TeeChart.Styles.FastLine(tChart1.Chart)
fastLine1.FillSampleValues()
Next
End Sub
In your project, implementing PrintToolStripMenuItem_Click like this:
Code: Select all
Private Sub PrintToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PrintToolStripMenuItem.Click
Dim i As Int32
'PageSettings()
OrgChart1 = CType(panels(0).Controls.Item(0), Steema.TeeChart.TChart)
OrgChart1.Printer.BeginPrint()
For i = 1 To 4 'panels.Length - 1
Try
OrgChart1.Printer.Print(CType(panels(i).Controls.Item(0), Steema.TeeChart.TChart).Chart, New Rectangle(100, (i * 200), 300, 200))
Catch ex As Exception
End Try
Next
OrgChart1.Printer.Print(New Rectangle(100, (i * 200), 300, 200))
OrgChart1.Printer.EndPrint()
'myDocument1.PrintController = New System.Drawing.Printing.StandardPrintController()
'myDocument1.DefaultPageSettings.Landscape = True
'myDocument1.DefaultPageSettings.Margins.Left = 100
'myDocument1.DefaultPageSettings.Margins.Top = 100
'myDocument1.Print()
'OrgChart1.Printer.Print(New Rectangle(100, (i * 200) + 10, 300, 200))
'OrgChart.Printer.Print() ' This call only prints the origChart and nothing else. Where as the call to printpreview shows all charts - why?
'OrgChart1.Printer.Preview() ' Only one page is supported? How to get charts to "spill over" to additional pages?
End Sub
Also works fine. Is this what you expect?
Thanks in advance.