Dear visitor, welcome to Jabaco - Community.
If this is your first visit here, please read the Help. It explains in detail how this page works.
To use all features of this page, you should consider registering.
Please use the registration form, to register here or read more information about the registration process.
If you are already registered, please login here.
JBGrid scoll to first and last row
Hi again,
is there someone that can help me?
I have a JBGrid with a scroll bar.
I also have a button called top and one called bottom.
How can i enable first row when i press TOP and how can i move to last when i press BOTTOM?
Thanks in advanced!
RE: JBGrid scoll to first and last row
Short answer:
How can i enable first row when i press TOP
|
Jabaco Source
|
1
2
3
4
5
|
Public Sub Command1_Click()
Dim v As javax#swing#JViewport = JBGrid1.getViewPort
v.setViewPosition(New Point(0,0))
JBGrid1.setViewport(v)
End Sub
|
and how can i move to last when i press BOTTOM?
|
Jabaco Source
|
1
2
3
4
5
|
Public Sub Command2_Click()
Dim v As javax#swing#JViewport = JBGrid1.getViewPort
v.setViewPosition(New Point(0,99999))
JBGrid1.setViewport(v)
End Sub
|
Last one is only a dirty hack. I have had known how to find out the maximum. But currently, I don't remember. So I used a big number (9999) instead.
RE: RE: JBGrid scoll to first and last row
and how can i move to last when i press BOTTOM?
|
Jabaco Source
|
1
2
3
4
5
|
Public Sub Command2_Click()
Dim v As javax#swing#JViewport = JBGrid1.getViewPort
v.setViewPosition(New Point(0,99999))
JBGrid1.setViewport(v)
End Sub
|
Last one is only a dirty hack.
Here a better solution:
|
Jabaco Source
|
1
2
3
4
5
6
7
8
9
10
|
Public Sub Command2_Click()
Dim v As javax#swing#JViewport = JBGrid1.getViewport
Dim vpos As Single = v.getViewSize.getHeight-v.getViewRect.getHeight
If vpos<0 Then
v.setViewPosition(New Point(0,0))
Else
v.setViewPosition(New Point(0,vpos))
End If
JBGrid1.setViewport(v)
End Sub
|
And with this you can go to top and bottom, without changing the view position in X:
|
Jabaco Source
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
Public Sub Command1_Click()
Dim v As javax#swing#JViewport = JBGrid1.getViewPort
v.setViewPosition(New Point(v.getViewPosition.getX,0))
JBGrid1.setViewport(v)
End Sub
Public Sub Command2_Click()
Dim v As javax#swing#JViewport = JBGrid1.getViewport
Dim vpos As Single = v.getViewSize.getHeight-v.getViewRect.getHeight
If vpos<0 Then
v.setViewPosition(New Point(v.getViewPosition.getX,0))
Else
v.setViewPosition(New Point(v.getViewPosition.getX,vpos))
End If
JBGrid1.setViewport(v)
End Sub
|
I will try you solutions.
Thank you very much for your help.
It is good that you are here, all of you, and help as.
Thanks again.
Hey there,
or try this
|
Jabaco Source
|
1
2
3
4
5
|
'scroll to last row
JBGrid1.Parent.changeSelection(JBGrid1.Rows - 1, 0, False, False)
'scroll to firs row
JBGrid1.Parent.changeSelection(0, 0, False, False)
|
If you don't want the rows to be selected
(JBGrid1.Rows, 0, False, False)
(-1, 0, False, False)
Dani