There is no scroll when we see only part of the column

Posted by: dror_farhi on 9 October 2018, 12:34 am EST

  • Posted 9 October 2018, 12:34 am EST

    Hi,

    I have an active x control that I am using on vb6:
    We currently updated this control from vaSpread version: 2.5.0.1, to the new fpSpread version 8.0.28.

    In the old control when adding column to grid, and we can only see part of it due to grid width, there is scroll bar.


    In the new control when adding column to grid, and we can only see part of it due to grid width, there is no scroll bar, and we can only see part of the added column.


    When adding 2 columns in the new grid (one that we partially see, and another one that we cannot see at all, the scroll appears, and we can scroll to see the 2 columns.

    What should I do in order to see 1 column that I'm adding to the grid. For now I can only see it partially ?

    I'm adding the column with the code:
    .Action = 6 'SS_ACTION_INSERT_COL

    Thanks,
    Dror Farhi
  • Replied 10 October 2018, 1:02 am EST

    Hello,

    If you do not need to the scrollbar, you may call AutoSize property for Spread which will adjust the width and height of Spread as per the rows and columns.
    To view the scrollbar, you would need to decrease the width of Spread control or add more columns to enable the scrollbar.
    Please make sure you have ScrollBarShowMax set to true.
    fpSpread1.ScrollBarShowMax = True

    And also ScrollBarExtMode is set to False.

    Thanks,
    Deepak Sharma
  • Replied 10 October 2018, 6:04 pm EST

    Hi,

    I cannot call AutoSize property cause the grid width should be fixed, in order to match the other controls on page.

    I cannot decrease the width of the grid for the same reason: grid width should be fixed.

    I cannot add another column, cause the user will use the scroll and see a blank column.

    Changing the propery: fpSpread1.ScrollBarShowMax to True, creating horizontal and vertical scroll all the time, even when the columns and rows fit inside the grid.

    Is there a more elegant solution ?

    Thanks,

    Dror Farhi
  • Replied 11 October 2018, 6:23 pm EST

    Hello Dror,

    In your code it seems you have set 'fpSpread1.ScrollBarExtMode = True' which means the scrollbar will appear only when needed. Now when the width of Spread is enough to show all columns the scrollbar would not appear.
    It will only appear when total width of columns exceeds the width of Spread control, instead of using the 'ScrollBarExtMode', you can handle it in code:

    Private Sub Command1_Click()
    fpSpread1.MaxCols = fpSpread1.MaxCols + 1
    Dim i, fWidth, finalWidth As Integer
    For i = 1 To fpSpread1.MaxCols
    fWidth = fpSpread1.ColWidth(i)
    finalWidth = finalWidth + fWidth
    Next i
    If finalWidth > fpSpread1.Width Then
    fpSpread1.ScrollBars = ScrollBarsHorizontal
    End If
    End Sub


    Please refer to the attached sample application.

    Thanks,
    Deepak Sharma
    SpreadCOMScrollBarWidthIssue.zip
  • Replied 13 October 2018, 10:42 pm EST

    Hi,

    Thanks for your answer.

    I used your code and debug it, but I cannot understand something:
    finalWidth = 109
    fpSpread1.Width = 7335

    So there is no horizontal scroll by our code.
    But actually when you look in the screen finalWidth is bigger than fpSpread1.Width, and we don't see the last column.

    Is there a problem with our measures ?

    Dror Farhi.


  • Replied 14 October 2018, 5:13 pm EST

    Hello Dror,

    'finalWidth' depends on the number of columns's width. The total width of columns can be more than the width of Spread and this is the case that we have to look for.
    In finalWidth you would need to include the width of Row header, VerticalScroll for accurate results.

    Thanks,
    Deepak Sharma

  • Replied 14 October 2018, 10:33 pm EST

    Hi,

    Even if I include everything, how can I go from 109 to 7335 ? ? ?
    I am not aiming for accurate result, only for reasonable one.

    When you say row header what do you mean ?
    I'm trying to sum column width, is it not include the row header ?

    Don't you think we are missing something ?



    Thanks,
    Dror Farhi
  • Replied 15 October 2018, 10:30 pm EST

    Hello,

    It looks that UnitType is not set to to Twips in your project. Please use the code :
    fpSpread1.UnitType = UnitTypeTwips

    to set the UnitType.

    You would need to explicitly find the RowHeader width. To include Row header and get the total width you can start the loop from '0' instead of '1'. For example:

    Private Sub Command1_Click()
    fpSpread1.MaxCols = fpSpread1.MaxCols + 1
    Dim i, fWidth, finalWidth As Integer
    For i = 0 To fpSpread1.MaxCols
    fWidth = fpSpread1.ColWidth(i)
    finalWidth = finalWidth + fWidth
    Next i
    If finalWidth > fpSpread1.Width Then
    fpSpread1.ScrollBars = ScrollBarsHorizontal
    End If
    End Sub
    Private Sub Form_Load()
    fpSpread1.UnitType = UnitTypeTwips
    fpSpread1.MaxCols = 6
    'fpSpread1.ScrollBarExtMode = True
    fpSpread1.ScrollBars = ScrollBarsNone

    fpSpread1.ColWidth


    End Sub




    Thanks,
    Deepak Sharma

  • Replied 15 October 2018, 10:48 pm EST

    Hi,

    Now finalWidth = 1050 and fpSpread1.Width = 7335.
    It's still looks unreasonable.

    How can I find row header width in order to add it to final width ?

    Thanks,

    Dror Farhi
  • Replied 17 October 2018, 1:50 am EST

    Hello Dror,


    Did you check the application I provided to you? It makes the scrollbar visible if the width of the columns is more than the width of the Spread control.
    Let me know if it behaves differently at your end?

    Thanks,
    Deepak Sharma
  • Replied 17 October 2018, 4:20 pm EST

    Yes,

    And on the provided application the measures are OK, and it works.
    On my application the sum of the columns isn't close to the grid width,
    that's why I think I 'm missing something.

    Thanks,

    Dror Farhi
  • Replied 17 October 2018, 4:57 pm EST

    The problem is with ColWidth of specific column:
    On my application 10 to 15
    On your example application: 960

    In my application column width is determined on code. It's global value that is used for a lot of fpSpread grids:

    fpSpread1.ColWidth(TargetCol) = SampleColumnWidthArray(Sample_Peak1Result) '15

    Maybe that's the problem.

    Beside that, the only properties that are different between the 2 fpSpread grids are:
    AutoCalc, AutoClipboard, GridShowVert, ProcessTab, RetainSelBlock, RowHeadersShow, UserResize.

    Thanks,
    Dror Farhi

  • Replied 17 October 2018, 11:16 pm EST

    Hello,

    Please provide me your application or a sample application, so that I check it at my end and look for a solution.

    Thanks,
    Deepak Sharma
  • Replied 23 October 2018, 3:52 am EST

    Hi,

    I have more urgent question:
    In the old control when we want to hide column, we did:
    spread.ColHidden = True
    If we want to show it again we did:
    spread.ColWidth(index) = 14 'for example.

    In the new control it doesn't work. When we do:
    spread.ColWidth(index) = 14
    spread.ColWidth(index) remains 0 on debug.

    To solve it in the new control, I did:
    To hide the column:
    spread.ColWidth(index) = 0 ' instead of spread.ColHidden = True
    To show it again:
    spread.ColWidth(index) = 14 'Now it works

    It seems to work. Is there any difference between:
    spread.ColHidden = True
    spread.ColWidth(index) = 0

    I'm afraid that I'm creating another bug with this solution.

    Thanks,
    Dror Farhi

  • Replied 23 October 2018, 4:33 pm EST

    Hello,

    There is no need to set the width of hidden column. You can directly set the ColHidden property to False to unhide the column.


    Private Sub Command1_Click()
    fpSpread1.Col = 2
    fpSpread1.ColHidden = True


    End Sub

    Private Sub Command2_Click()
    fpSpread1.Col = 2
    fpSpread1.ColHidden = False
    End Sub


    Please refer to the attached sample.

    Thanks,
    Deepak SharmaSpreadHideShowColumn.zip
  • Replied 23 October 2018, 6:54 pm EST

    Hi,

    I know that fpSpread1.ColHidden = True will hide the column,
    but after that, when I will want to show it again and change the width, I should write 2 lines:
    fpSpread1.ColHidden = False
    fpSpread1.ColWidth(index) = 14

    I asked if instead of the solution above I can do: fpSpread1.ColWidth(index) = 0 to hide the column, and after that only 1 line of code to show the column and change the width:
    fpSpread1.ColWidth(index) = 14

    You have to understand: I'm changing the control in application from the 90's with more than millions of lines, I need the shortest solution. Please help me.

    Can I do: fpSpread1.ColWidth(index) = 0 to hide the column ?

    Thanks,
    Dror Farhi

  • Replied 24 October 2018, 2:34 am EST

    Hi,

    About the problem with the scrolls, I created a sample application as you asked.
    Please pay attention to my comments.

    Thanks,
    Dror FarhifpSpread scroll.zip
  • Replied 25 October 2018, 10:24 pm EST

    Hello,

    I modified your sample application code like below:

    Private Sub Command1_Click()
    fpSpread1.UnitType = UnitTypeTwips
    fpSpread1.MaxCols = fpSpread1.MaxCols + 1
    Dim i, fWidth, finalWidth As Integer
    For i = 1 To fpSpread1.MaxCols
    fWidth = fpSpread1.ColWidth(i)
    finalWidth = finalWidth + fWidth
    Next i
    If finalWidth > fpSpread1.Width Then 'If you will put break point over here you will see finalWidth = 118 and fpSpread1.Width = 3975, so we will never enter to this condition.
    fpSpread1.ScrollBars = ScrollBarsHorizontal

    End If
    End Sub

    It seems to work fine. If we do not change the UnitType for Spread then the width of the columns will always be lesser than the width of the Spread.

    For other issue, you would have to set the 'ColHidden' property of the the to 'False' for column in order to make it visible again.

    Thanks,
    Deepak Sharma
  • Replied 29 October 2018, 2:22 am EST

    Hi,

    About the scrolls: When I run:
    fpSpread1.ScrollBars = ScrollBarsHorizontal on my application
    The grid still doesn't contain Horizontal scroll. Should I add Redraw, Refresh or something else?

    About the other issue:
    I didn't ask if I need to set ColHidden to False in order to make the column visible.
    I asked if I can set fpSpread1.ColWidth(index) = 0 instead of fpSpread1.ColHidden = True, in order to hide the column ?
    After I set fpSpread1.ColWidth(index) = 0 the column became hidden. In order to show it again I set fpSpread1.ColWidth(index) = 14. Just to understand: You say that fpSpread1.ColWidth(index) = 14 after fpSpread1.ColWidth(index) = 0 isn't enough ? I also need to set: fpSpread1.ColHidden = False in order to show the column ?
    Please answer me in details, so I can fully understand the correlation between these properties

    Thanks,
    Dror Farhi

    Thanks
  • Replied 29 October 2018, 6:10 pm EST

    Hi Dror,

    1. It shows the horizontal scrollbar here in my application no matter the size or number of columns in Spread.
    I used 'fpSpread1.ScrollBars = ScrollBarsHorizontal', you can try calling the redraw property.

    2. Sorry for the confusion, here is how the hide unhide works
    Case 1: Setting the Column Width to 0.
    In this case the width of the column needs to be regained in order to make it visible. Setting ColHidden property to false will not have any effect.

    Case 2: Hiding the column by setting ColHidden property.
    In this case the ColHidden property needs to be set to False to make the column visible. Setting col width to something other than 0 will not have any effect.

    I hope I am able to clear the doubt you had. Please refer to the attached sample application for better understanding.

    Thanks,
    Deepak Sharma
    SpreadHideShowColumn.zip
  • Replied 31 October 2018, 5:07 am EST

    Hi,

    Everything works fine, except that even when ScrollExtMode = False, it is still shows vertical scroll when there is enough height for all rows. Do you know why ?

    Thanks,
    Dror Farhi

  • Replied 31 October 2018, 5:11 am EST

    My mistake I'm checking it again
  • Replied 1 November 2018, 1:43 am EST

    Hello,

    Please check and let me know if the issue still persists.

    Thanks,
    Deepak Sharma
  • Replied 1 November 2018, 3:08 am EST

    Hi,

    ScrollExtMode = True, suppose to create vertical and horizontal scroll if needed. Am I right ?
    It works OK for vertical scroll, but doesn't work for horizontal scroll.
    That's why I added the calculations as you wrote.
    My code looks like this:
    With sprdTable
    .UnitType = UnitTypeTwips

    Dim Idx, iFinalWidth As Integer
    For Idx = 0 To .MaxCols
    iFinalWidth = iFinalWidth + .ColWidth(Idx)
    Next Idx
    If iFinalWidth > .Width Then
    Select Case .ScrollBars
    Case ScrollBarsNone
    .ScrollBars = ScrollBarsHorizontal
    Case ScrollBarsVertical
    .ScrollBars = ScrollBarsBoth
    End Select
    Else
    Select Case .ScrollBars
    Case ScrollBarsBoth
    .ScrollBars = ScrollBarsVertical
    Case ScrollBarsHorizontal
    .ScrollBars = ScrollBarsNone
    End Select
    End If
    .UnitType = UnitTypeVGABase
    End With

    The problem is, that in design mode, I have already defined ScrollBars = 3 - ScrollBarsBoth
    So when FinalWidth > .Width, I do not enter to the select case:
    Select Case .ScrollBars
    Case ScrollBarsNone
    .ScrollBars = ScrollBarsHorizontal
    Case ScrollBarsVertical
    .ScrollBars = ScrollBarsBoth
    End Select
    But still, even when .ScrollBars = ScrollBarsBoth, only the vertical scroll appears.
    What am I doing wrong ?

    Thanks,
    Dror Farhi


  • Replied 1 November 2018, 4:37 am EST

    Hi,
    Another problem:
    When there is vertical scroll, and we have for example the second row selected, when we move to another page and return to the same page, the selected row appears as the first one on spread grid, and you have to scroll up to see the first row that isn't selected.
    The customer wants that the scroll will be up, and when we navigate to the page we will see the first row.
    Do you know how to do that ?

    Thanks,
    Dror Farhi
  • Replied 2 November 2018, 1:04 am EST

    Hello,

    For the first issue, I am not able to replicate the same with the sample I provided earlier, please provide me your sample to test why horizontal scrollbars are not re-appearing.

    For second issue, you can show the cell on an action, performed by the user
    fpSpread1.ShowCell 0, 0, PositionUpperLeft

    Thanks,
    Deepak Sharma
  • Replied 5 November 2018, 3:46 am EST

    Hi,
    Finally I found the problem with the scrolls:
    ScrollExtMode = True suppose to create scrolls when needed. There is no need to calculate columns width. (That's not an elegant solution, especially for a control that was bought)
    The problem is that in the old control, when the grid was filled with data, you can added more columns, and fill them from the other columns data.
    In the new control when you do it, it ruins the scroll. You need to create the schema of the grid (empty grid), and only after that fill the columns. When you add columns to a filled grid, it ruins the scrolls. That's why I saw only half of column without scroll.
    The problem now is that I'm puking blood in order to change the fill of the grid, cause in a lot of grids we are adding columns in the middle of the grid and fill them from another columns that shifted right because of the adding of the columns.
    Is there a way (some property or something else), that allow to add columns to a filled grid, without ruining the scroll ?

    Thanks,
    Dror Farhi

  • Replied 6 November 2018, 4:45 am EST

    Hi,

    Thanks for your help. I finally succeed to fix the scroll when ScrollExtMode = True.

    But there is still one problem.
    When there are 8 columns (the number of VisibleCols), the horizontal scroll still appears:


    Why the scroll appears if the columns are fit to the grid width ?

    When I click between the horizontal scroll and it's arrow - here:


    I'm getting an unexpected result:


    The first column: "Inj #" that we are still see is FrozenCol.

    How can I fix this problem and get rid of the gray area ?

    Thanks,
    Dror Farhi
  • Marked as Answer

    Replied 8 November 2018, 12:17 am EST

    Hello,

    I have asnwered it here:
    https://www.grapecity.com/en/forums/spread-com/scroll-problems

    Thanks,
    Deepak
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels