in vb.net i would like to draw a regular line on a form. is there a control to do this?
Click and drag to draw, then release the mouse button to cement the shape. You can click and drag the line around after it's cemented. To delete a line, click it to select it and then press the Delete key. Add more lines.
VBA userforms do not have a builtin shape control for drawing lines or circles. You can mimic vertical and horizontal lines by using a label with no caption and a value of 1 for the width or height. I have an example file for using autoshape displayed as images which allows for a more rich drawing experience. Maybe this is something you could use.
Typically, when you draw on a form, you handle the form’s Paint event and perform the drawing using the Graphics property of the PaintEventArgs, as shown in this example The preceding example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler.
However, if you want to have a visual control that you can drag on to a form, add the Microsoft.VisualBasic.PowerPack to your visual studio toolbox. To do that right-click on toolbox select "Choose Items...". Locate "Line Shape" on the .Net Framework Components tab.
What Mitch Wheat said is generally regarded as the correct answer, and what I have done in the past. However, if you want to have a visual control that you can drag on to a form, add the Microsoft.VisualBasic.PowerPack to your visual studio toolbox. To do that right-click on toolbox select "Choose Items...". Locate "Line Shape" on the .Net Framework Components tab.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With