|
-
Dec 21st, 2006, 11:32 PM
#1
Thread Starter
New Member
Form focus
hi all,
i have a Windows Form with a bunch of texboxes and combobox in it .
When i'm running the app and filling out the form , I want to click on the form itself so no control has the focus . I thought by clicking on the form itself will make all controls lose the focus , but somehow that is not the case and the last control used still has the focus .
is this a bug or am i missing something here , do i need to set a property in the form ?
is there a way to make the form gain the focus so that no controls has the focus ?
thanks,
hang
-
Dec 21st, 2006, 11:38 PM
#2
Re: Form focus
If a form contains any controls that can receive focus then one of them always will have focus. What you ask for is not possible, at least using the .NET Framework anyway. Perhaps it's possible using the Windows API but not that I'm aware of.
Why do you want this anyway. My guess is that you're trying to accomplish something that really doesn't need to be done.
-
Dec 21st, 2006, 11:42 PM
#3
Re: Form focus
Forget everything I just said. I just tried setting the form's ActiveControl property to Nothing and "hey presto"! Note that this must be done from inside the form itself.
-
Dec 21st, 2006, 11:57 PM
#4
Thread Starter
New Member
Re: Form focus
 Originally Posted by jmcilhinney
Forget everything I just said.  I just tried setting the form's ActiveControl property to Nothing and "hey presto"! Note that this must be done from inside the form itself.
i will try it tomorrow but i think you answer my question ...
do i need to put that one line code in the Form_load event or the Form_focus event ??
here is an explanation as to my question, I have a bunch of combobox in a Windows form and my users like to use the mouse wheel to scroll and i'm afraid if the focus is on the combobox, they will accidentally change the answer in the combobox, so i want my users to click on the form and then scroll using the mousewheel.
Because my users are used to doing that in web pages, where when you click
on the webpage itself, all webpage's controls lose focus and they can scroll the web page using the mousewheel .
thanks,
hang
-
Dec 22nd, 2006, 12:14 AM
#5
Re: Form focus
If you want something to happen when the form is clicked then you need to do it in the form's Click event handler.
-
Dec 22nd, 2006, 12:22 AM
#6
Thread Starter
New Member
Re: Form focus
 Originally Posted by jmcilhinney
If you want something to happen when the form is clicked then you need to do it in the form's Click event handler.
*bang my head on the wall*
on Form_click
form1.activecontrol = nothing
thanks,
hang
-
Dec 22nd, 2006, 12:29 AM
#7
Re: Form focus
VB Code:
Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click
Me.ActiveControl = Nothing
End Sub
-
Dec 22nd, 2006, 11:30 AM
#8
Thread Starter
New Member
Re: Form focus
 Originally Posted by jmcilhinney
VB Code:
Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click
Me.ActiveControl = Nothing
End Sub
Thanks for the answer.
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
|