Drawing in vb.net

Source: Internet
Author: User

In the project, a chart is used to display the opening degree of a valve and the opening degree of the control valve. I used to use the pie chart in the control bought by any company, but I think it is also troublesome. I just want to draw it by myself.

First, add a TrackBar named "TrackBar1", a label named "L_A_SHANG", a GroupBox named "GB_RIGHT", and then add the processing function when pulling the scroll bar.

PC Control
Dim m_start As Integer
Dim RcDraw As System. Drawing. Rectangle


Private Sub TrackBar1_Scroll (ByVal sender As Object, ByVal e As System. EventArgs) Handles TrackBar1.Scroll
M_start = (100-TrackBar1.Value)
Me. L_A_SHANG.Text = Me. TrackBar1.Value. ToString
GB_RIGHT.Invalidate () redraw GB_RIGHT
End Sub

Processing function when GB_RIGHT is added for repainting

Private Sub GB_RIGHT_Paint (ByVal sender As Object, ByVal e As System. Windows. Forms. PaintEventArgs) Handles GB_RIGHT.Paint
RcDraw. X = TrackBar1.Location. X-40
RcDraw. Y = 20
RcDraw. Height = 100
RcDraw. Width = 20
E. Graphics. DrawRectangle (New Pen (Color. Blue, 5), RcDraw)
Dim I = TrackBar1.Location. X-40
For I = TrackBar1.Location. X-40 To TrackBar1.Location. X-20
E. Graphics. DrawLine (New Pen (Color. Blue, 5), I, m_start + 20, I, 120)
Next

Me. L_A_SHANG.Text = Me. TrackBar1.Value. ToString + "%"
End Sub

At this point, the image changes and the percentage is displayed.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.