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!

Exclude selected DBGrid Rows

Status
Not open for further replies.

lespaul

Programmer
Feb 4, 2002
7,083
US
I have a DBGrid that shows all the people who should have showed up for an event. I have MultiSelect, RowSelect, and AlwaysShowSelection marked as True. I have a DrawColumnCell Event that if the row is selected it turns red. Once the user has selected all the people who DID NOT ATTEND I want to update all the other people and exclude the rows that were marked. Can anyone think of a way to accomplish this??

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

SELECT * FROM USERS WHERE CLUE > 0
No Rows Returned
 
Working in reverse to what you want to do:

I've not used the std grids in a while, but you should be able to do something like:


var1 := := 0;
while grid.SelectedCount > var1 do
begin
Gridsdataset.bookmark := grid.SelectedRows[var1];
Do Stuff - maybe update a calculated field???
inc(var1);
end;

Then loop through your dataset and update the records you have not marked as being OK.

A bit of a long winded way of doing things, but then again so is noting who didn't turn up rather than those who did. Robertio
Alias: Robbie Calder
Software Developer
urc@walkermartyn.co.uk
 
I'll give that a try! Thanks Robbie. As far as noting who didn't turn up rather than those that did, here's what I've got if you've got a better suggestion:

I have a list of 20 - 30 people per group (at least one group each morning and sometime an afternoon group) and every other week 150 - 200 at an orientation, most of whom show up when scheduled. I had originally planned on having the user select those who attended. Except almost every one usually shows up. So instead of having the user select all the people who were there, I thought I would have them mark the one or two who were not there.

Any better thoughts?

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

SELECT * FROM USERS WHERE CLUE > 0
No Rows Returned
 
Hi ,

I do a similar thing..I show a grid with about 200 entries, out of which most are to be updated, while a few are to be ignored.

I show all entries in the grid, and below the grid i have a button 'SELECT ALL'.
when you click the button all the entries in the grid are selected...
after that the user hold the CTRL key and unselects a few records that are to be ignored.

you can try a similar approach, of course , not compulsary that you have a button to click, you can call the procedure automatically.

here is the code on the button click

Query1.First;
while not Query1.eof do
begin
DBgridd.SelectedRows.CurrentRowSelected:=True;
Query1.Next;
end;

then the user unselects whichever records he desires










 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top