VB.net to implement drawing, and TrackBar and draw the binding of graphics

Source: Internet
Author: User
Tags tostring
Graphics

Graphics are used to show the opening of a valve and the opening of the control valve. Originally is to use what company to buy the control in the pie chart and so on, but I think it is trouble, think, or painting it yourself.

First add a trackbar, the name is "TrackBar1", a label, the name is "L_a_shang", a GroupBox, the name is "Gb_right", and then add the processing function when pulling the scroll bar

' Host computer 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 () ' re-painting gb_right
End Sub

Add a handler function when Gb_right is repaint

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 +, I, 120)
Next

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

When this and the pull bar can be implemented, the image changes and displays the percentage.




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.