VB.net Drag and drop from one cell on a DataGridView to another

Hi

What VB.net code would I use to drag from one DataGridView cell to another leaving both cells color as yellow and not dragging any values?
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jacques Bourgeois (James Burger)PresidentCommented:
What is the logic of dragging without transferring a value? This would be counter-intuitive for the user.
0
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
The logic is to highlight the cells as a pair
0
Jacques Bourgeois (James Burger)PresidentCommented:
Personally, I feel that something like that would be better done another way.

When the user drags, he expects a transfer, either a copy or a move.

When he needs to select many elements together, the standard is Ctrl-Click.

Unless you use Ctrl-Click for something else in the grid, I would go that route. Not only will it be easier to code, but it will be more natural for the user. On the first Ctrl-Click, you set the first cell to yellow, and on the second Ctrl-Click, you set the second cell.

You can trap a Ctrl-Click with code like the following:

	Private Sub DataGridView1_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellClick
		If Control.ModifierKeys = Keys.Control Then
			'Do what you need
		End If
	End Sub

Open in new window


If you expect to make more than one such pairs, you should think of using different colors for each pair.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks very much
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.