Click here to Skip to main content
13,458,880 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


3 bookmarked
Posted 24 Jan 2013

C# Selector Tool

, 24 Jan 2013
Rate this:
Please Sign up or sign in to vote.
A simple selector tool in C#.


While working on one of my latest projects, I found myself in need of a simple region selection tool. Pressed with more important functions that my app should provide, I tried searching around the web for a code, just like many times before. After a while, it was clear to me that I’ll have to do the job myself and here it is! You can take the code and implement it however you prefer.

Using the code

It doesn’t really require a lot of code, just some creative thinking to get you on the right track. To give you a basic idea of what it’s all about, here’s a code that allows you to define a selection component into a simple form.

Selection selection = null;
public Form1()
    selection = new Selection(this);

The selection is then implemented in a picture box class with defined methods events regarding specific mouse movements.

private void pictureBox1_Paint(object sender, PaintEventArgs e)

private void pictureBox1_MouseDown(object sender, MouseEventArgs e)


private void pictureBox1_MouseUp(object sender, MouseEventArgs e)

private void pictureBox1_MouseMove(object sender, MouseEventArgs e)

Of course, this is not all the work you need to do. It’s not all that simple, but it explains the logic behind solving the problem. The form above above just calls for a Selection.cs file which handles the rest. If you believe this can help you, the full code and the demo are available to the rest of the community here at CodeProject. Play around with it, use it in your apps, or just show off in front of your friends. A lot of the guys here have helped me on more than one occasion, so this is my way of saying: “Thank you!”


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

You may also be interested in...


Comments and Discussions

Praisethanx Pin
Member 120369289-Nov-15 23:36
memberMember 120369289-Nov-15 23:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.180323.1 | Last Updated 24 Jan 2013
Article Copyright 2013 by Damir Sarcevic
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid