Gridview Scroll issue

Post

Posted
Rating:
#1 (In Topic #140)
Avatar
Guru
cogier is in the usergroup ‘Guru’
I want to display the last item(s) on a GridView display, not the first. I can do it but the values needed make no sense to me. Have a look at the attached program that demonstrates my query.

Thanks.
Attachment

Code (gambas)

  1. Public Sub ButtonStart_Click()                                      'When the 'Start' Button is clicked...
  2. Dim iCount As Integer                                               'Counter
  3.  
  4. GridView1.Rows.count = 101                                          'Amount of Rows needed
  5. GridView1.Columns.count = 1                                         'Amount of Columns needed
  6.  
  7. For iCount = 0 To 100                                               'Count from 0 to 100
  8.   GridView1[iCount, 0].Text = Str(iCount)                           'Add the value to a 'Cell'
  9.  
  10. For iCount = 0 To 2200                                              'Count from 0 to 2200
  11.   GridView1.Scroll(0, iCount)                                       'Move the 'Scroll Bar'
  12.   LabelNumber.text = "GridView1.Scroll(0, " & Str(iCount) & ")"     'Display the values
  13.   Wait                                                              'Loop through the event loop
  14.   If iCount > 2100 Then Wait 0.25                                   'Slow things down at the end so that they can be seen
  15.  
  16. Catch                                                               'If you close the program while it is busy this will stop an error
  17.  
  18.  
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Regular
stevedee is in the usergroup ‘Regular’
I think your MagicNumber should just be replaced with the ScrollHeight, e.g.

Code (gambas)

  1. For iCount = 0 To GridView1.ScrollHeight
  2.  

…then you don't need to worry about how the scroll is scaled internally.
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Regular
stevedee is in the usergroup ‘Regular’
Also, if you change your row count to 100, you can use a simple fraction or multiplier to display any row e.g.

Code (gambas)

  1. GridView1.Rows.count = 100                                        'Amount of Rows needed
  2. GridView1.Columns.count = 1                                         'Amount of Columns needed
  3.  
  4. For iCount = 0 To 99                                               'Count from 0 to 100
  5.   GridView1[iCount, 0].Text = Str(iCount)                           'Add the value to a 'Cell'
  6. Me.text = GridView1.ScrollHeight
  7. For iCount = 0 To GridView1.ScrollHeight / 2                'to display row 50
  8.   GridView1.Scroll(0, iCount)                                       'Move the 'Scroll Bar'
  9.   LabelNumber.text = "GridView1.Scroll(0, " & Str(iCount) & ")"     'Display the values
  10.   Wait                                                              'Loop through the event loop
  11.  

…or;

Code (gambas)

  1. For iCount = 0 To (GridView1.ScrollHeight * 0.75)    'to display row 75
  2.  


…or maybe something like;

Code (gambas)

  1. intStopAtRow = 75
  2. intStopAtRow = (intStopAtRow / GridView1.Rows.Count) * GridView1.ScrollHeight
  3.  
  4. For iCount = 0 To intStopAtRow
  5.  
Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Guru
cogier is in the usergroup ‘Guru’
Thanks SteveDee. By using GridView1.Scroll(0, GridView1.ScrollHeight) the scroll bar moves to the end of the data. I think that 'ScrollHeight' is a strange name for this thought. I changed the code in my 'problem' to the following: -

Code (gambas)

  1. Public Sub ButtonStart_Click()                                      'When the 'Start' Button is clicked...
  2. Dim iCount As Integer                                               'Counter
  3.  
  4. GridView1.Rows.count = 101                                          'Amount of Rows needed
  5. GridView1.Columns.count = 1                                         'Amount of Columns needed
  6.  
  7. For iCount = 0 To 100                                               'Count from 0 to 100
  8.   GridView1[iCount, 0].Text = Str(iCount)                           'Add the value to a 'Cell'
  9.  
  10. GridView1.Scroll(0, GridView1.ScrollHeight)                         'Move the 'Scroll Bar' to the end
  11.  
  12. Catch                                                               'If you close the program while it is busy this will stop an error
  13.  
Online now: No Back to the top
1 guest and 0 members have just viewed this.