That does fix the problem outlined above, however, now I am getting a different error when there are 2 grids using same IGPrintManager. I seem to have narrowed it down to the 2 grids having a different number of columns.
This time the error happens before the preview displays.
System.ArgumentOutOfRangeException: 'Specified argument was out of the range of valid values.'Below is the code to demonstrate it.
To get the error:
1. Click PrintButton and it will preview the first grid. (no errors)
2. Click PrintButton2 and it will give you the error.
If you click PrintButton2 first, it will work, and then if you click PrintButton (the first one) it will work too, but then when you then click the PrintButton2 again, you get the error then as well.Was it not designed to be used like this?
I hope that makes sense. If you have trouble duplicating it, please let me know.
Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
With IGrid1
With .Cols
.Add("Category", "Category")
.Add("Sub-Category", "Sub-Category")
.Add("Description", "Description") ' everything works if you remove this line
End With
For i As Integer = 0 To 5
Dim newRow As iGRow = .Rows.Add()
newRow.Cells("Category").Value = "cat " & i
newRow.Cells("Category").SpanCols = .Cols.Count
Next
End With
With IGrid2
With .Cols
.Add("Category", "Category")
.Add("Sub-Category", "Sub-Category")
End With
For i As Integer = 0 To 5
Dim newRow As iGRow = .Rows.Add()
newRow.Cells("Category").Value = "cat " & i
newRow.Cells("Category").SpanCols = .Cols.Count
Next
End With
End Sub
Private Sub PrintButton_Click(sender As Object, e As EventArgs) Handles PrintButton.Click
IGPrintManager1.Grid = IGrid1
IGPrintManager1.PrintPreview()
End Sub
Private Sub PrintButton2_Click(sender As Object, e As EventArgs) Handles PrintButton2.Click
IGPrintManager1.Grid = IGrid2
IGPrintManager1.PrintPreview()
End Sub
Edited by user
2021-06-24T01:15:17Z
|
Reason: Not specified