A Question of form focus - VB.NET 2003

  • Thread starter Thread starter Sid Price
  • Start date Start date
S

Sid Price

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.
 
Sid said:
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
 
Chris said:
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.
 
Back
Top