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!

DBGrid - keep selected rows colored?

Status
Not open for further replies.

lespaul

Programmer
Feb 4, 2002
7,083
US
I implemented Steph DrawColumnCell example from the FAQ, which is great except I need the selected rows to stay colored! I have multiselect = True and can multiselect, but as soon as I select a 2nd row, the first row changes it's color back! Is there any way to color a row when selected and keep it colored when the next row is selected? Also how can I access the bookmarks that indicate a row is selected? I want to be able to execute an insert/update query based on which rows WERE NOT SELECTED. Any clue?

Thanks! Leslie
landrews@metrocourt.state.nm.us

SELECT * FROM USERS WHERE CLUE > 0
No Rows Returned
 
So nobody knows how to keep a selected row colored when the next row is selected???? Leslie
landrews@metrocourt.state.nm.us

SELECT * FROM USERS WHERE CLUE > 0
No Rows Returned
 
The usual way is to hold down the ctrl key when clicking on the record in the DBGrid.

This is the Windows way of selecting multiple records and is probably what your users will expect.


Andrew
 
The list of selected rows is held in the SelectedRows property of the DBGrid.

This is a list of bookmarks which is what you wanted.

Andrew
 
Hi,

and just for display convenience you might want to set the Option dgAlwaysShowSelection as well; from the online help: "The selected cell displays the focus rectangle even when the grid does not have focus". The default is "false".

Cheers,
Matthias
 
Ok, so I have AlwaysShowSelection = True and that's working like a charm. Thanks Matthias!

Why is row one always selected? Is there anyway to default to nothing selected?

Now that I have my grid with the selected rows colored, I want to start back at the first row and if the row is selected SKIP it for the processing. However if I do .FIRST, all my selections disappear and every row gets updated. How can I loop through all the rows and skip the row if it's selected?

Thanks! Leslie
landrews@metrocourt.state.nm.us

SELECT * FROM USERS WHERE CLUE > 0
No Rows Returned
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top