We help IT Professionals succeed at work.

How to select many controls together in VB.Net

binu_star
binu_star asked
on
Medium Priority
745 Views
Last Modified: 2007-12-19
Hi,
  I am creating a windows application and have a groupbox on my form. Few controls are created at runtime and are placed on this groupbox. Now i need to select multiple controls at runtime by just clicking and dragging the mouse as allowed in Windows operating system. As of now, i am doing by clicking on the each controls, but i want to use my mouse to select many controls together by just clicking and dragging the mouse towards the controls that need to be selected. This is very much important for my project and i would like to express my thanks in advance for all the comments.
Comment
Watch Question

Commented:
I made such things on VC++ and have no ready .NET code for this. So, I only can describe the general idea, hope this can help. I will talk about selection of any objects in the window client area (controls, graphic objects etc.).

1) Left mouse button down event. If point doesn't belong to any object, start net selection mode. Set capture to this window, Keep two points: srart of selection rectangle and current point (they are equal in the beginning). Let's call them pStart and pCurrent. Use DrawFocusRect API to draw rectangle (pStart, pCurrent) - it draws point in the beginning.

2) Mouse move event. If we are in net selection mode:
Call DrawFocusRect to draw (pStart, pCurrent). This will remove previous rectangle - calling DrawFocusRect  a second time with the same rectangle removes the rectangle from the screen. Keep current mouse position in pCurrent and call DrawFocusRect again - in the new place.

3) Left mouse button up event. Release capture. If we are in net selection mode:
Call DrawFocusRect to draw (pStart, pCurrent) - remove rectangle.
Keep current mouse position in pCurrent.
Select all objects intersecting with (pStart, pCurrent) rectangle.

If you know VC++, you can read this algorithm in MFC sample DRAWCLI.

Author

Commented:
I haven't recieved any suitable answer in dotnet. So i request you to close the question and refund my points.

Commented:
binu_star, you got algorithm how to do this. Did you try to implement it? Do you have some specific problems? You ask the same question third time and get first reply. However, you don't post any comment, and now you ask to close the question.

Author

Commented:
Hii Alex,
   First of all, i would like to apologise to you for not getting back to these question. I had tried to do with your algorithm, but couldn't use the API due to the arguments to be passed. I would be happy if you can send me the code for that in .Net.
   Actually since i had to go on to further module of my project, i left off this module as of now. But i don't have any problems in giving you the points. I would appreciate if you can send me the code in .net as i am new to .Net.

Author

Commented:
I don't feel this is justified. Neither did i get the correct solution nor did i get my points back. I request you to reopen the question as i need a solution for that.

Binu

Commented:
I am worling with this. You may reopen question, however.
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Commented:
If you want to continue using EE, try to talk more with experts and not with moderators.

Author

Commented:
Hi
  I am sorry. I was not in station and couldn't access these comments for last few days. I have got a new job and am moving to Seattle, Washington. Anyway thanks for sending me these valuable comments. I must accept Alex's comments as i think it might work. I couldn't implement as i am no longer working in the project. But i will try to use it in a sample and will send you feedback soon. Thanks a lot.

Author

Commented:
Hii
   I would like to suggest moderators to give the users more time before closing any question. As in my case, i was so busy fot last 2 months, that i could hardly use experts exchange. But that doesn't mean that i am not gonna use it ahead. i have got so many useful comments and wanna get your service ahead too. But try to give more time before closing any question.

Author

Commented:
Hi Alex,
   Thanks for your comment. Its working on the form but i need to draw this rectangle on the groupbox. I tried to change the event handling, but it's not working. Can you please tell me, if you know, what all changes i have to make to display rectangle on groupbox.

Author

Commented:
Hi GhostMod,
    I appreciate your response and look forward to further co-ordination.
Thanks,
 Binu.

Commented:
Do you want this inside of group box or on the whole form, both inside and outside of group box?
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.