0
votes

I have a vb.net application that has a list of reports that you can select from.
When you select a report it loads the data and displays the report in the Crystal Report Viewer. However, The report display is way to big and the only way to resize it is to restore down the screen and then restore it to full screen. The scroll bars are only visible after you restore the page down and up.

The generated code for the viewer is as follows.

Me.CrystalReportViewer1.ActiveViewIndex = -1
    Me.CrystalReportViewer1.AutoValidate = System.Windows.Forms.AutoValidate.EnablePreventFocusChange
    Me.CrystalReportViewer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
    Me.CrystalReportViewer1.Cursor = System.Windows.Forms.Cursors.Arrow
    Me.CrystalReportViewer1.DisplayBackgroundEdge = False
    Me.CrystalReportViewer1.Dock = System.Windows.Forms.DockStyle.Fill
    Me.CrystalReportViewer1.EnableDrillDown = False
    Me.CrystalReportViewer1.Location = New System.Drawing.Point(230, 0)
    Me.CrystalReportViewer1.Name = "CrystalReportViewer1"
    Me.CrystalReportViewer1.SelectionFormula = ""
    Me.CrystalReportViewer1.ShowCloseButton = False
    Me.CrystalReportViewer1.ShowGroupTreeButton = False
    Me.CrystalReportViewer1.ShowRefreshButton = False
    Me.CrystalReportViewer1.ShowTextSearchButton = False
    Me.CrystalReportViewer1.Size = New System.Drawing.Size(517, 715)
    Me.CrystalReportViewer1.TabIndex = 1
    Me.CrystalReportViewer1.ToolPanelView = CrystalDecisions.Windows.Forms.ToolPanelViewType.None
    Me.CrystalReportViewer1.ViewTimeSelectionFormula = ""

I am calling it like this:

Dim rpt As String
    rpt = ListBox1.Items(ListBox1.SelectedIndex)
    If Not CrystalReportViewer1.ReportSource Is Nothing Then CrystalReportViewer1.ReportSource.dispose()

    Select Case rpt
        Case "Scoot"
            myreport = New graduation
            LoadDatabaseInfo(myreport)
            myreport.SetParameterValue("doop", indrno.Text)
            'myreport.SetParameterValue("dte", indate.Value)
            myreport.SetParameterValue("name", txb.Text)
            CrystalReportViewer1.ReportSource = myreport
            CrystalReportViewer1.Refresh()
            CrystalReportViewer1.Zoom(55)

How do I fix This.. Thank you so much

2

2 Answers

0
votes

Rather than zooming to 55 percent, try using a value of 1 to fit to the width of the page or 2 to fit in the page (from MSDN).

0
votes

I was able to accomplish my resizing needs by setting the height and width properties of the window to set pixel values.

i.e.

  CrystalReportViewer.Width = 1100
  CrystalReportViewer.Height = 1200

It takes some playing around to get your values correct but this worked and I didn't have any zooming issues.