How to dynamically set page length in data report?
Hi,
I need to set the page length dynamically in the data report. Any way to do it?
Need:
I wish to generate a invoice bill with food items. Based on the items the bill length varies. Thats why i need.
Or
Any other ways to accomplish the above thing.
Advance thanks,
Senthil
Re: How to dynamically set page length in data report?
Moved to reporting section.
Re: How to dynamically set page length in data report?
Hi,
I'm having the same problem myself and im just wondering did you ever come up with a solution?
thanks
Re: How to dynamically set page length in data report?
There is no Page Length property for a DataReport. I don't understand. No matter how many items you print the paper size your printing on stays the same. If you describe your problem better maybe someone can help.
Re: How to dynamically set page length in data report?
The problem that I am having is that I am creating a receipt using a reportviewer in vb pro 2012. I have it working great until there are loads of items on the receipt which need printed because then a scroll bar appears and unless the user scrolls down to view the other items they are not displayed. I have tried using auto scroll = false, auto size = true and also tried using the scrollable print option on the print form component. The reportviewer is being displayed on a form and what I need is for the form and reportviewer to get longer based on how many items there are in the report so that the full thing can be printed. Any help or advice would be greatly appreciated.
Re: How to dynamically set page length in data report?
First, I think you would have better luck if you posted this in the VB .Net Forum. It doesn't sound like your even printing a report, your printing the form,
Quote:
tried using the scrollable print option on the print form component
Though you should be using a report.
Changing the size of the form and reportviewer wouldn't be hard, just change the size property. I don't know how you're retrieving your data, but you need to find a way to get the count of the line items in order to determine if you need to change the form size.
Re: How to dynamically set page length in data report?
Ive already tried to use the size property to fix my problem but it never made a difference, I have also tried to use auto size and disable the scroll bar but nothing has worked. I am using a reportviewer control that takes up the whole of the form. The code that I have behind the form is below:
Code:
Imports System.Data.OleDb
Imports System.IO
Imports System.Drawing.Printing
Public Class Receipt
Public PicLocation As String
Dim Ctrl1, Ctrl2 As Control
Dim CN As New OleDb.OleDbConnection
Dim CMD As New OleDb.OleDbCommand
Dim DataR As OleDb.OleDbDataReader
'To display into datagrid purpose
Dim dataS As New DataSet
Dim dataAd As New OleDb.OleDbDataAdapter
Public SqlStr, SqlStr1, DBPath, DBStatus, SearchBox As String
Dim X, Y, SqlH, Onh As Integer
Dim SqlUser As String
Dim DataP As Decimal
Dim Balance As Integer
Private Sub Receipt_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'ProductListDataSet' table.
DBPath = (Application.StartupPath & "\ProductList.accdb")
If CN.State = ConnectionState.Open Then
CN.Close()
DBStatus = ("Not Connected")
End If
SqlStr = ("Provider = Microsoft.ACE.OLEDB.12.0;Data Source =" & DBPath)
CN.ConnectionString = SqlStr
CN.Open()
Onh = Nothing
lblTime.Text = DateAndTime.Now
lblUser.Text = Login.userTB.Text
Dim sql As String
sql = "SELECT * Receipt"
Me.ReceiptTableAdapter.ClearBeforeFill = True
Me.ReceiptTableAdapter.Connection = CN
Me.ReceiptTableAdapter.Connection.CreateCommand.CommandText = sql
Me.ReceiptTableAdapter.Fill(Me.ProductListDataSet.Receipt)
Me.ReportViewer1.RefreshReport()
Me.Refresh()
End Sub
Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
With Me.PrintForm1
.PrintAction = Printing.PrintAction.PrintToPrinter
Dim MyMargins As New Margins
With MyMargins
.Left = 0
.Right = 0
.Top = 0
.Bottom = 0
End With
.PrinterSettings.DefaultPageSettings.Margins = MyMargins
.Print(Me, PowerPacks.Printing.PrintForm.PrintOption.CompatibleModeClientAreaOnly)
End With
End Sub
End Class
Re: How to dynamically set page length in data report?
It looks like your using the PrintForm control. Sorry, I've never used it. Seems like a report like rdlc/crystal/printdocument would work better. Maybe you can find some helpful information thru Google. Good luck.
Re: How to dynamically set page length in data report?
I cant find anything through Google thats why I joined the forum.
Ive tried using a PrintDocument control as well and I got more output using the PrintForm.
Thanks anyway.
Re: How to dynamically set page length in data report?
Given that the data you have is already in a database table (or query) I think your best bet is to look at a reporting tool - either Crystal Reports or SSRS are the most commonly used.
PrintForm is a bad choice as it only prints what is displayed on a form as it is displayed - so any cut-off records will not print.
If you are feeling brave you can write your own print code using PrintDocument - it is quite involved but it does give you a very high degree of control over the results. In that case you should start by reading the Beginner's guide to printing in .NET
Re: How to dynamically set page length in data report?
Thanks Merrion.
I'll give that a go!