Hi All,
I am using the following code to build a dual temperature scale in Visual Basic.
I have built the picture box in a container with a button in a separate cell and when I debug the button does not appear until you physically move the form. If I remove the button its fine.
If I remove the code at the bottom pictherm1.Image = bmp1 its fine but the scale does not build.
If I build the form without containers its also fine and builds correctly with the button.
Please can anyone help
Thank you in advance
Nevjc
Imports System.Drawing.Drawing2D
Imports System.IO.Ports
Public Class Form1
Dim bmp1 As Bitmap = New Bitmap(165, 550)
Dim temperature1 As Double = 10
Dim temperature2 As Double = 10
Dim WithEvents sp As New SerialPort
Private Sub pictherm1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles pictherm1.Paint
Dim g As Graphics = Graphics.FromImage(bmp1)
g.Clear(Color.White)
If temperature1 > 100 Then temperature1 = 100
g.FillRectangle(Brushes.Green, 48, 525 - CInt(temperature1 * 5), 10, CInt(temperature1 * 5))
If temperature2 > 100 Then temperature2 = 100
g.FillRectangle(Brushes.Green, 108, 525 - CInt(temperature2 * 5), 10, CInt(temperature2 * 5))
g.DrawLine(Pens.Black, 60, 525, 60, 25)
g.DrawLine(Pens.Black, 105, 525, 105, 25)
For i As Integer = 25 To 525 Step 5
g.DrawLine(Pens.Black, 50, i, 60, i)
g.DrawLine(Pens.Black, 105, i, 115, i)
Next
Dim f As Font = New Font("Verdana", 10, FontStyle.Regular)
Dim scale As Integer
For i As Integer = 525 To 25 Step -25
g.DrawLine(Pens.Black, 45, i, 60, i)
g.DrawLine(Pens.Black, 105, i, 120, i)
scale = (525 - i) / 5
g.DrawString(Str(scale), f, Brushes.Black, 65, i - 8)
Next
pictherm1.Image = bmp1
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
End Class