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

Network Availability _+ Main Form Status Bar

P: n/a
If the network cable is unplugged I need to change an image on my main form
status bar, however this does not work

' The computer has been connected or disconnected from the network
If e.IsNetworkAvailable = False Then
My.Forms.MainForm.usbtest.Panels(2).Appearance.Ima ge =
My.Resources.server_error
Else
My.Forms.MainForm.usbtest.Panels(2).Appearance.Ima ge =
My.Resources.server_ok
End If

If I put the following in the main form load it works fine
usbtest.Panels(2).Appearance.Image = My.Resources.server_ok
Aug 1 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
My guess is since the network is available the logic in
MyApplication_NetworkAvailability does not fire as my code acted the same as
yours.

Private Sub MyApplication_NetworkAvailabilityChanged(ByVal sender As
Object, ByVal e As Microsoft.VisualBasic.Devices.NetworkAvailableEven tArgs)
Handles Me.NetworkAvailabilityChanged
SetConnectionStatus(e.IsNetworkAvailable)
End Sub
Public Sub SetConnectionStatus(ByVal connected As Boolean)
If Not (connected) Then
frmMainForm.ToolStripStatusLabel1.Image = My.Resources.NetDown
Else
frmMainForm.ToolStripStatusLabel1.Image = My.Resources.NetUp
End If
End Sub

Private Sub frmMainForm_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If My.Computer.Network.IsAvailable Then
ToolStripStatusLabel1.Image = My.Resources.NetUp
Else
ToolStripStatusLabel1.Image = My.Resources.NetDown
End If
End Sub

"Rocky" <Ro***@discussions.microsoft.comwrote in message
news:F2**********************************@microsof t.com...
If the network cable is unplugged I need to change an image on my main
form
status bar, however this does not work

' The computer has been connected or disconnected from the
network
If e.IsNetworkAvailable = False Then
My.Forms.MainForm.usbtest.Panels(2).Appearance.Ima ge =
My.Resources.server_error
Else
My.Forms.MainForm.usbtest.Panels(2).Appearance.Ima ge =
My.Resources.server_ok
End If

If I put the following in the main form load it works fine
usbtest.Panels(2).Appearance.Image = My.Resources.server_ok

Aug 1 '07 #2

P: n/a
It does fire, I think the problem is accessing the main form.

"Kevin S Gallagher" wrote:
My guess is since the network is available the logic in
MyApplication_NetworkAvailability does not fire as my code acted the same as
yours.

Private Sub MyApplication_NetworkAvailabilityChanged(ByVal sender As
Object, ByVal e As Microsoft.VisualBasic.Devices.NetworkAvailableEven tArgs)
Handles Me.NetworkAvailabilityChanged
SetConnectionStatus(e.IsNetworkAvailable)
End Sub
Public Sub SetConnectionStatus(ByVal connected As Boolean)
If Not (connected) Then
frmMainForm.ToolStripStatusLabel1.Image = My.Resources.NetDown
Else
frmMainForm.ToolStripStatusLabel1.Image = My.Resources.NetUp
End If
End Sub

Private Sub frmMainForm_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If My.Computer.Network.IsAvailable Then
ToolStripStatusLabel1.Image = My.Resources.NetUp
Else
ToolStripStatusLabel1.Image = My.Resources.NetDown
End If
End Sub

"Rocky" <Ro***@discussions.microsoft.comwrote in message
news:F2**********************************@microsof t.com...
If the network cable is unplugged I need to change an image on my main
form
status bar, however this does not work

' The computer has been connected or disconnected from the
network
If e.IsNetworkAvailable = False Then
My.Forms.MainForm.usbtest.Panels(2).Appearance.Ima ge =
My.Resources.server_error
Else
My.Forms.MainForm.usbtest.Panels(2).Appearance.Ima ge =
My.Resources.server_ok
End If

If I put the following in the main form load it works fine
usbtest.Panels(2).Appearance.Image = My.Resources.server_ok


Aug 1 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.