By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,888 Members | 1,432 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,888 IT Pros & Developers. It's quick & easy.

A Question of form focus - VB.NET 2003

P: n/a
Is there a way of stopping a form getting focus in VB.NET. The scenario I
have is a main form and a form used for display only. There are no user
controls on the display form and it does not ever need to have the focus.
When the displays on the form are updated it appears to get the focus. I
would like to prevent this because if the user operates any hot-keys
(thinking the main form still has focus) these keys will fail.

I have tried saving the display form's owner in a variable and then
executing the following in my UpdateDisplay method. However the focus
remains with the display form, when I had hoped it would be set to the main
form (the display forms owner).

mOwner.Select()

I have also tried:

mOwner.Focus()

Neither of which seem to work.

Many thanks,
Sid.
Apr 22 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Sid Price wrote:
Is there a way of stopping a form getting focus in VB.NET. The scenario I
have is a main form and a form used for display only. There are no user
controls on the display form and it does not ever need to have the focus.
When the displays on the form are updated it appears to get the focus. I
would like to prevent this because if the user operates any hot-keys
(thinking the main form still has focus) these keys will fail.

I have tried saving the display form's owner in a variable and then
executing the following in my UpdateDisplay method. However the focus
remains with the display form, when I had hoped it would be set to the main
form (the display forms owner).

mOwner.Select()

I have also tried:

mOwner.Focus()

Neither of which seem to work.

Many thanks,
Sid.


Just because you update some controls on a form it should not get focus.
You may want to show the code that causes the form to get focus.

Chris
Apr 22 '06 #2

P: n/a
"Chris" <no@spam.com> wrote in message
news:uP**************@TK2MSFTNGP05.phx.gbl...
Sid Price wrote:
Is there a way of stopping a form getting focus in VB.NET. The scenario I
have is a main form and a form used for display only. There are no user
controls on the display form and it does not ever need to have the focus.
When the displays on the form are updated it appears to get the focus. I
would like to prevent this because if the user operates any hot-keys
(thinking the main form still has focus) these keys will fail.

I have tried saving the display form's owner in a variable and then
executing the following in my UpdateDisplay method. However the focus
remains with the display form, when I had hoped it would be set to the
main form (the display forms owner).

mOwner.Select()

I have also tried:

mOwner.Focus()

Neither of which seem to work.

Many thanks,
Sid.


Just because you update some controls on a form it should not get focus.
You may want to show the code that causes the form to get focus.

Chris


This is the mothod that updates the controls on the form:

Private Sub UpdateDisplay()

Dim iSeconds As Integer = iValue Mod 60

Dim iMinutes As Integer = iValue \ 60

Dim strDisplay As String

If iSeconds < 10 Then

strDisplay = iMinutes & ":0" & iSeconds

Else

strDisplay = iMinutes & ":" & iSeconds

End If

ledCount.Text = strDisplay

End Sub

Sid.
Apr 22 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.