|
-
Nov 21st, 2008, 06:10 PM
#1
Thread Starter
Not NoteMe
[RESOLVED] [3.0/LINQ] Allow inherited control to be selectable and have focus
I have a control that inherits from UserControl and i want it to be selectable and to receive input focus. (I need to be able to give it focus and make it selectable through code).
I've tried setting the controlstyle to selectable, hiding the inherited CanSelect/CanFocus properties (using new bool ....) but even that doesn't give the control focus when i do MyControl.Focus() and ParentForm.ActiveControl = this.
Any ideas?
Last edited by SLH; Nov 23rd, 2008 at 06:43 AM.
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
-
Nov 21st, 2008, 11:33 PM
#2
Re: [3.0/LINQ] Allow inherited control to be selectable and have focus
What you're doing is wrong. A UserControl is supposed to be a container for multiple child controls. That's what the UserControl class exists for. If you want to make a control that can receive focus then you should be inheriting the Control class, not the UserControl class.
-
Nov 22nd, 2008, 05:47 AM
#3
Thread Starter
Not NoteMe
Re: [3.0/LINQ] Allow inherited control to be selectable and have focus
Ahhh that explains it! Thanks for the tip. (I love being able to write a question before i go to bed and get an answer when i wake up!!).
Rating++
EDIT: Looks like you help me too often, can't give you rep until i've given it to others.
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
-
Nov 22nd, 2008, 08:04 AM
#4
Thread Starter
Not NoteMe
Re: [3.0/LINQ] Allow inherited control to be selectable and have focus
Hmm, i now have my class inheriting from Control, rather than UserControl and it still has CanFocus and CanSelect returning false even with me hiding the inherited versions and setting the selectable style for my control.
Any ideas, do i need to inherit some other control that allows focus?
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
-
Nov 22nd, 2008, 07:22 PM
#5
Re: [3.0/LINQ] Allow inherited control to be selectable and have focus
I've never actually developed a custom control myself so I'm not sure of all the details. I think at least you have to call SetStyle in the constructor and set the Selectable style. I'd go to MSDN and do some reading on authoring custom controls.
-
Nov 23rd, 2008, 05:57 AM
#6
Thread Starter
Not NoteMe
Re: [3.0/LINQ] Allow inherited control to be selectable and have focus
I did have a search around before posting, but i'll have another go if no-one else has any ideas.
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
-
Nov 23rd, 2008, 06:42 AM
#7
Thread Starter
Not NoteMe
Re: [3.0/LINQ] Allow inherited control to be selectable and have focus
I used a .net reflector to see what CanFocus and CanSelect did internally.
Seems that they actually do some low-level looking at window handles.
Because of what i'm doing with the control and form (rendering it via XNA) the functions always return false. Soooo.... i've just created several methods that hide all the selection and focusing related functions.
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|