shawnlehner
asked on
Refreshing Object on Form
I am using a graphics box for a graphic load bar.... when I change the width what is the best way to refresh the bar because sometimes it does not update.
'Also call update after invalidate to syncronize it.
NameOfControl.Invalidate()
NameOfControl.Update()
NameOfControl.Invalidate()
NameOfControl.Update()
...or just call the controls Refresh() method:
NameOfControl.Refresh()
NameOfControl.Refresh()
ASKER
ok how would I refresh an object on frmMain from a different form?
You need a reference to frmMain from your secondary form:
Public Class frmMain
Inherits ...
Public Sub Button1_Click(...) Handles Button1.Click
Dim f2 As New Form2
f2.fMain = Me
f2.Show()
End Sub
End Class
Public Class Form2
Inherits ...
Public fMain As frmMain
Private Sub foo()
If Not (fMain Is Nothing) Then
fMain.Label1.Text = "Something..."
fMain.Label1.Refresh()
End If
End Sub
End Class
Public Class frmMain
Inherits ...
Public Sub Button1_Click(...) Handles Button1.Click
Dim f2 As New Form2
f2.fMain = Me
f2.Show()
End Sub
End Class
Public Class Form2
Inherits ...
Public fMain As frmMain
Private Sub foo()
If Not (fMain Is Nothing) Then
fMain.Label1.Text = "Something..."
fMain.Label1.Refresh()
End If
End Sub
End Class
ASKER
Below code does not work... gives me an invalid instance code... help?
Dim mainForm As frmMain
overallRun = overallRun + EventsFinished
overallWidth = Convert.ToInt32((overallRu n / overallCount) * 436)
mainForm.loadbarOverall.Wi dth = overallWidth
mainForm.loadbarOverall.In validate()
mainForm.loadbarOverall.Re fresh()
Dim mainForm As frmMain
overallRun = overallRun + EventsFinished
overallWidth = Convert.ToInt32((overallRu
mainForm.loadbarOverall.Wi
mainForm.loadbarOverall.In
mainForm.loadbarOverall.Re
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
NameOfControl.Invalidate()