×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

allowing in a grid to use shift and ctrl key to select rows

allowing in a grid to use shift and ctrl key to select rows

allowing in a grid to use shift and ctrl key to select rows

(OP)
Hi everyone,
since i am very new to this vfp, specially 9.0 sp2. here is my question.

I have a grid where i can have a bunch of records/rows, so sometimes it could be a lot of rows that need to be deleted, so i was thinking instead of select one by one to delete a row, if i can use shift and arrow down or mouse click and hilite the rows, or ctrl key and mouse click and hilite the rows and if it is possible to accomplish it ?
i know i can create a check mark column to tick and untick but i don't want to use that method, so i am wondering if we can accomplish what i mentioned aboveif so ,can anyone please guide me here ?

thanks in advance

RE: allowing in a grid to use shift and ctrl key to select rows

Not as easy as it should be, but not impossible.

The first idea to consider is to use a listbox in place of the grid. The listbox control has a MultiSelect property, which enables exactly the behaviour you want. However, a listbox is not as efficient as a grid for working with very large tables. It also had the disadvantage that the data cannot be directly edited, as it can with a grid.

If that doesn't suit you, you might be able to achieve your goal by means of the DynamicBackColor and DynamicForeColor properties (note that these are properties of the column, not the grid). You will need a new logical field in the underlying table, and you will need to arrange for that field to be toggled when the user selects a row while Ctrl and/or Shift is pressed. The DynamicXXXColor properties would test for the setting of the logical field, and change the colours of the row accordingly.

If you need any more help with the above properties, see Conditional formatting in a Visual FoxPro grid.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: allowing in a grid to use shift and ctrl key to select rows

(OP)
Hi Mike,
the thing is, that i need to select first, a row with a shift+ mouse click or ctrl+mouse click, and then hilite those rows, i guess then issuing it, this should use the underlying field assigned and then make it as .T. ,then in my delete click event just delete for that field=.T.

but what i don't see is, how to bind this keys, shift, ctrl and mouse click to make those rows to get hilited.
i understand that we need to use the keypress property of the grid and define there, the key pressed but what can i use in nkeycode for combining shift+ down arrow, or shift+mouse right click, or ctrl+ mouse right click and so on, this is the part i don't see, sorry for so many question, as you said it is a little complicated specially for me.
Thanks

RE: allowing in a grid to use shift and ctrl key to select rows

(OP)
Mike,
Don't worry i believe, that i should add a checkbox and delete for ticked rows, so whatever is ticked, then delete them, will be easier, of course it is always to be able to learn other tricks
Thanks in advance.

RE: allowing in a grid to use shift and ctrl key to select rows

Well, I agree that the checkbox approach would be much simpler. But to answer your question, I think you would need to use the MouseDown event rather than the Keypress to trap the "modifier" keys (Ctrl, Shift, Alt). But it's not that simple, because you would also have to check to see if the row was already highlighted when the user clicks in it; and, if it was, you would need to un-highlight it. It gets even more complicated when you consider they might be highlighting a range of rows, but then want to un-highlight one or more rows within that range.

So, yes, go with the checkbox approach. But consider also highlighting the row in some way when the box is checked, to give the user a strong visual indication of which rows are about to be deleted. I think you'll find this approach is acceptable to your users. They might even find it easier than the Shift / Ctrl approach.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close