What method would I use to draw a simple line that is 1 pixel thick?
Printable View
What method would I use to draw a simple line that is 1 pixel thick?
VB Code:
Picture1.Line (0, 0)-(100, 100)
If you have Picture1.AutoRefresh = False (default), then you can have this at Picture1_Paint. If you have AutoRefresh set then you should never have anything at the Paint event or you'll get stuck.
For a straight line in any angle or thickness, use the line control in your toolbox.
Threads merged. :)
What I wanted to do was draw a line on a button control that I have. I want to just draw a simple shape. I could use an image, yes, but why add unnecessary files to my project.
You could set a borderless picturebox with Enabled = False on top of a command button to get the wanted effect. If you want to work pixelwise, set ScaleMode of the picturebox to vbPixels. The click goes through of not enabled elements so it is as if you click the button even when you know there is a picturebox on top of a command button.
The reason you cant draw a line using the line control or label control is that they are drawn on the background layer. Where as command buttons are drawn on the top most layer. You need to use a control, like suggested, that is on the same layer or use a series of pictureboxes with images ofr theup and down positions.