Print Search Rate
    
   10-27-2005, 1:50 PM
DynamiCube Horizontal Scrollbar
Attachment: dcHorizontalScrollBar.zip

When row fields or column fields have several data items with long captions, the screen area DynamiCube needs to properly display the content may not be available. Also, the scrollbars DynamiCube offers are only available in the data area.

You can allow your users to scroll through row fields by adding a horizontal scrollbar to the project and displaying the scroolbar only when necessary (i.e. when DynamiCube is too narrow for all of the data items in the row fields to be visible). In this sample we place the scrollbar in a picture box control.

First, create a method that returns the width of the row area.

  
Public Function GetRowAreaWidth() As Long
Dim cnt As Long
Dim iTotalWidth As Long
Dim iMaxDepth As Long
Dim arrRowFields As Variant

If m_Cube.RowFields.Count = 0 Then Exit Function

'Find which field is drilled down the most.
Do While cnt <= m_Cube.RowCount - 1
If m_Cube.GetRowDepth(cnt) > iMaxDepth Then
iMaxDepth = m_Cube.GetRowDepth(cnt)
End If
cnt = m_Cube.GetNextRow(cnt)
Loop

ReDim arrRowFields(m_Cube.RowFields.Count - 1)

'Store the field order.
For cnt = 0 To m_Cube.RowFields.Count - 1
arrRowFields(m_Cube.RowFields(cnt).Position) = cnt
Next cnt

'Calculate the width of the row fields.
For cnt = 0 To UBound(arrRowFields)
iTotalWidth = iTotalWidth + m_Cube.RowFields(arrRowFields(cnt)).Width
If cnt >= iMaxDepth - 1 Then Exit For
Next cnt

'Return the calculated width of the row fields.
GetRowAreaWidth = iTotalWidth

End Function

Then, create a method that determines whether to display a scroll bar.

  
Private Sub DisplayCubeWithScroll()
Dim lngRowWidth As Long
Const SCROLL_HEIGHT As Long = 225

'Find out the width of the row fields area.
lngRowWidth = GetRowAreaWidth

'If we need to display the scrollbar, display it. Otherwise hide it.
If lngRowWidth >= m_PictureBox.ScaleWidth - 500 Then
m_Scrollbar.Visible = True
m_Scrollbar.Move m_PictureBox.ScaleLeft, m_PictureBox.ScaleHeight - SCROLL_HEIGHT, m_PictureBox.ScaleWidth, SCROLL_HEIGHT
Call SetScrollingValues
Call PositionCube
Else
m_Scrollbar.Value = 0
m_CubeOffset = 0
m_Scrollbar.Visible = False
m_Cube.Move m_PictureBox.ScaleLeft, m_PictureBox.ScaleTop, m_PictureBox.ScaleWidth, m_PictureBox.ScaleHeight
End If

End Sub

Once you make this method available, you can call it any time the user pivots or resizes the form.

The code samples provided in this article are excerpts from the attached sample which includes one for DynamiCube 2.x and one for DynamiCube 3. For a demonstration of the approach discussed here, please refer to the sample attached using the same version of DynamiCube that you use. Also, please feel free to use this code as is, or as a starting point in your own application.

If you have any questions regarding DynamiCube, contact our support team by submitting a support request.



Applies To:
DynamiCube 2.5
DynamiCube 3.0
GrapeCity » Knowledge Base » KnowledgeBase f... » DynamiCube Horizontal Scrollbar
Privacy Policy | Copyright © 1997-2012 — GrapeCity, inc.
All trademarks mentioned are the property of their respective owners.