Connecting Tech Pros Worldwide Forums | Help | Site Map

Selectable User-Drawn Control

Newbie
 
Join Date: Jan 2009
Posts: 2
#1: Jan 7 '09
Hi all.
I've built a class based on "Control" and I want this object of mine to be
selectable. I believe that, by default, Control is non-selectable so I used
this.SetStyle(ControlStyles.Selectable, true);

And it works fine when I use TAB key, but when I click on my object, the
focus remains on the current object.

What am I doing wrong?

TIA

tlhintoq's Avatar
Moderator
 
Join Date: Mar 2008
Location: Arizona, USA
Posts: 1,781
#2: Jan 9 '09

re: Selectable User-Drawn Control


One though: Set the "Click" event of your control to this.Focus();
Newbie
 
Join Date: Jan 2009
Posts: 2
#3: Jan 9 '09

re: Selectable User-Drawn Control


Thanks, tlhintoq.
I've found a nice way in another thread.

if (this.CanSelect) this.Select();

I used this on override OnMouseDown
Reply