-
Apr 5th, 2002, 05:42 AM
#1
Thread Starter
Fanatic Member
Multiple Row Select on DataGrid
I know how to select multiple Rows on an ADO DataGrid by holding down the CTRL Key.
I would like to hold down the vbKeyShift to select Multiple rows at once. For example select row 1, hold down shift, select row 20 then rows 1 to 20 become Bookmarked.
I have trapped the Shift key in KeyDown, but the code I put in RowColumnChange works while the procedure is working, but all bookmarks are removed (or the grid clears these).
Code:
Private Sub grdItemData_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyShift Then
MultiLineSelect = True
End If
End Sub
Private Sub grdItemData_RowColChange(Index As Integer, LastRow As Variant, ByVal LastCol As Integer)
If MultiLineSelect = True Then
For myIndex = LastRow To grdItemData(Index).Row
grdItemData(Index).SelBookmarks.Add (myIndex)
Next myIndex
End If
End Sub
Help!
Mindcrime : )
ICQ 24003332
VB 5.0, VB 6.0 SP5, COM, DCOM, VB.NET Beta 2, Oracle 8
-
Apr 5th, 2002, 07:03 AM
#2
Frenzied Member
Use TrueDBGrid (www.componentone.com) - it allows multi-selection by simply changing a property.
'Buzby'
Visual Basic Developer
"I'm moving to Theory. Everything works there."
-
Apr 5th, 2002, 08:59 AM
#3
Thread Starter
Fanatic Member
I downloaded the eval version and it does allow this.
I think we will go down this route.
However I have acheived this using the ActiveX DataGrid (mention in my original thread).
Code:
Private Sub grdItemData_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyShift Then
MultiLineSelect = True
End If
End Sub
Private Sub grdItemData_RowColChange(Index As Integer, LastRow As Variant, ByVal LastCol As Integer)
If MultiLineSelect = True Then
MultiLineSelectStartRow = LastRow
MultiLineSelectEndRow = grdItemData(Index).Row
End If
End Sub
Private Sub grdItemData_KeyUp(Index As Integer, KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyShift Then
For myIndex = MultiLineSelectStartRow To MultiLineSelectEndRow
grdItemData(Index).SelBookmarks.Add (myIndex)
Next myIndex
MultiLineSelect = False
End If
End Sub
For those who want to be picky, it only shows the selection after the shift key is released.
But what the hell!
Mindcrime : )
ICQ 24003332
VB 5.0, VB 6.0 SP5, COM, DCOM, VB.NET Beta 2, Oracle 8
-
Jul 10th, 2018, 10:13 AM
#4
New Member
Re: Multiple Row Select on DataGrid
Hi,
I have a VB6 project that needs to be support for a while.
I have a question about the solution is provided here.
It works as long as the recordset is not filtered or sorted.
If you sort or filter, the .row index won't be sequential anymore and multi selection doesn't work properly.
Any solutions?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|