Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multi Select

Status
Not open for further replies.

filipe26

Programmer
Mar 17, 2003
152
PT
Hi i have a dbgrid in multiselect mode but how do i do if i want instead of select one by one with CTRL,for example holding SHIFT and select a Range by the first to the last and making a selecion range.Thanks.
 
You have to add code to do this (most of the 3rd party grids already have it).

The hard part is figuring out where the beginning is. You can update a TBookmarkStr in the BeforeScroll event and then check for
Code:
(ssShift in Shift)
in the MouseDown event.

If the Shift is down, you have to figure out if the starting row is "up" or "down" (you can usually tell by the active index value). Save a bookmark to the current row.

Start moving through the TDataSet until TDataSet.Bookmark = StartingBookmark (saved from BeforeScroll). On each row you want to select, use
Code:
TDBGrid.SelectedRows.CurrentRowSelected := True;

Finally, set
Code:
TDataSet.Bookmark := CurrentBookmark;
to go back to the row the user clicked.

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top