Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal Report Viewer 2

Status
Not open for further replies.

Ajb2528

Technical User
Feb 22, 2002
270
GB
Hi!,

I am using VB.NET2003 and Crystal 9 Advanced. I have developed a number of reports that are previewed using the Crystal viewer. My problem is that the viewer will not 'scroll' when using the mousewheel. Has anyone got a solution to this?

Regards,

Alan
 
Hi,

It sounds like the PageControl control (one of the controls on the viewer user control) doesn't have the correct focus.

Slim
 
Slim,

Thanks for the reply. How do I give the pagecontrol focus?

Regards,

Alan
 
It is not a fun or straight forward exercise but you can navigate the CrystalReportViewer's controls through its Controls property. You may have to descend a few layers as well.

What I recommend doing is entering break mode in the IDE and then browsing the Controls collection in the locals window. Once you locate a control that is of type PageControl, you can develop code that will search and access that control and call its Focus() method.

I have used this method to hijack the toolbar control and modify its buttons.

Code:
'This is a rough sketch
For Each Control ctl In CrystalReportViewer.Controls
   If ctl.GetType() = GetType(PageControl) Then
      ctl.Focus()
   End If
Next
 
Dalchri,

I have tried this code (or a variation of it) but cannot find a control called 'PageControl'. The nearest I can get to is a control called 'Pageview' but this still does not cure the problem...

Regards,

Alan

PS Here is my version of the code...

Dim thisObj As Object
For Each thisObj In crvMain.Controls
MessageBox.Show(UCase(thisObj.GetType.Name))
If UCase(thisObj.GetType.Name) = "PAGEVIEW" Then
thisObj.Focus()
End If
Next
 
Ajb, you're not looking for a control called "PageControl", you are looking for a control of type PageControl. The control could be named anything, that's why you have to search for the type.

-Rick

----------------------
 
You know, I just tried the mouse wheel in my CrystalReportViewer and it doesn't work with mine either. I can only assume that the viewer does not support the mouse wheel.

You might be able to manipulate the ScrollBar if you can find it in the Controls collection. Again, it might be a few layers down in the control hierarchy. You'd also need to capture the mouse wheel input to the CrystalReportViewer.
 
Another splendid effort from Crystal!!! But hey! they are normally about a decade behind everyone else in the technology front......
 
This code will at least get you to the PageControl alluded to earlier and capture the MouseWheel input. Attach to the MouseWheel event of the CrystalReportViewer:

Code:
Sub cvw_MouseWheel(sender As Object, e As MouseEventArgs)
Dim ctlPageview As Control = Null

For Each ctl As Control In cvw.Controls
   If (ctl.GetType() = GetType(PageView)) Then
      ctlPageview = CType(ctl, PageView)
   End If
Next

If ctlPageview <> Null Then
   Dim ctlDocument As DocumentControl = Null

   For Each ctl As Control in ctlPageview.Controls
      If ctl.GetType() = GetType(TabControl) Then
         ctlDocument = CType(CType(ctl, TabControl).SelectedTab, DocumentControl)
      End If
   Next

   If ctlDocument <> Null Then
      Dim pnt As Point = ctlDocument.AutoScrollPosition

      pnt.Offset(0, 5 * e.Delta)
      ctlDocument.AutoScrollPosition = pnt
   End If
End If
End Sub

This code doesn't quite scroll the page but it does at least move it. I'll leave it up to you to figure out exactly how to route the e.Delta into the AutoScrollPosition.

This is also developed using a very simple report model. Only one tab was present on the viewer. No drill downs, subreports, or anything else that produces an extra tab was present.

I think that the lack of mouse wheel support is a diffusion of responsibility between Microsoft and Crystal Reports. The DocumentControl inherits from TabPage inherits from ScrollableControl <- does not support the wheel mouse.

I apologize for any syntax errors, it was a hasty conversion from C#.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top