I am having a strange problem that is driving me crazy. I am drawing rectangles to a picturebox in my main form based on values entered in text boxes in a second form. It is working however if I change teh values in form 2 the changes do not show up in form 1 until I minimize and maximize form 1 or until I click another application to move my app to the background then click my ap to make it active. I think the problom has to do with redrawing the screen on an event but I cannot find any documentation on it. Here is some of my code if it helps. Thanks in advance for any help
Code:
Protected Overrides Sub OnPaint(e As PaintEventArgs)
me.Refresh()
Dim MEF As bitmap= new Bitmap(MEFBOX.Width,MEFBOX.Height)
Me.MEFBOX.Image=MEF
'Defines your graphics holder
Dim g As Graphics = Graphics.FromImage(MEF)
'Defines your 4 line colors
Dim fillcol As Color
'assigns variables to the text boxes
Dim WXTEXT As String="LGT RME ICG"
'Defines array for the SZL row
Dim x as integer
Dim SZLBOXES(23) As rectangle
'Set values for boxes
Dim SZLNUMS(23) As Integer
Dim Vals(23) As Integer
'Defines cases for colors of your lines
If szlwxval1=1 Then
fillcol=color.Green
ElseIf szlwxval1<5 Then
fillcol=color.Yellow
else fillcol=color.Red
End If
'Defines pens and brushes
Dim NPN As pen=new Pen(color.Red,3)
Dim BXBS As Solidbrush=new SolidBrush(fillcol)
Dim TXBS As Solidbrush=new SolidBrush(color.black)
Dim fnt as Font = new Font("Times New Roman", 10)
If SZLDLG.Visible=True Then
Me.ClientSize = New System.Drawing.Size(0, 0)
Else Me.ClientSize = New System.Drawing.Size(800, 600)
End If
'Defines SZL rectangle sizes
For x = box1val To box2val : szlboxes(x) = New Rectangle( (30*(x+1)), 10, 30, 20)
Next x
'Draw boxes
g.FillRectangles(bxbs,szlboxes)
g.DrawString(WXTEXT,fnt,TXBS,x,10)
'save drawing to picturebox
MEFBOX.Image.Save("C:\MISSION TRACKING\MEF\TEST.BMP")
End Sub
Private Sub KSZLBUTClick(sender As System.Object, e As System.EventArgs)
'Show SZL form
Me.ref
SZLDLg.Visible=true
End Sub
and form2
Code:
Private Sub SZLOKClick(sender As System.Object, e As System.EventArgs)
Dim MFM as new MainForm()
Dim SZLST1 As Integer
Dim SZLST2 As Integer
Dim SZLWeX1 as Integer
SZLST1=Me.SZLS1.text
SZLST2=Me.SZLE1.text
SZLWeX1=Me.SZLW1.Text
MFM.Box1Val=SZLST1
MFM.Box2Val=SZLST2
MFM.szlwxval1=SZLWex1
me.visible=False
MFM.Refresh()
MFM.
End Sub