UI Design

I want to draw out a few lines on a form at design time (like being in MS Paint or something). But the toolbox doesn't seem to have such an object in it, is there a com object I can import? if not that, can you draw an HTML table on a form object (that would achieve the same thing that I'm after)
Who is Participating?
Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
Amazingly enough...there are no static built-in line controls for you to use on your forms in the .Net Framework:

Some options:

   (1) Draw them at design time using the Paint() event of your form and the graphics supplied in the "e" parameter.

   (2) Add a Label to your form and set its height to 1 in the Size() property.  Change the BorderStyle to FixedSingle.  It's a pain to move the Label around though!

   (3) Do a Google search for "VB.Net Line Control"....

   (4) Write your own UserControl that is a line...
Well, I know there are several drawing functions built into VB .NET. As far as I know there aren't any MS-Paint style 'objects' you can import...

>> In order to use the built in drawing features, first create a graphics object:

Dim yourGraphicObj As Graphics = CreateGraphics()

>> You can then use that object to draw several shapes:

yourGraphicObj.DrawLine(New Pen(Drawing.Color.Red), 0, 0, 100, 100)

>> Play around with the functions and settings...

Hope that helps!

Concerning your question about HTML forms, I don't think you can draw an HTML form on the VB form object itself, although you can create a Windows webpage object and open a predefined HTML form in it:

>> Just right-click in your Toolbox when in design view and click "Add/Remove Items..."
>> Next, click the "COM Components" tab in the window that pops up. (It'll take a while to load...)
>> Then scroll down and check the "Microsoft Web Browser" box and click OK

Now you'll have a new "Microsoft Web Browser" object available in your toolbox. With it, you can add any size browser object to your form and tell it to load a certain HTML page which contains your HTML form.

In my opinion a custom line control would be most appropriate here. A quick guide on how to do it..

Add a few properties to hold the values for the different colors, i.e gradients etc
You can go as wild as you like with properties, and i guarentee that your new line control will be vastly more flexible than the old vb6 one
Ovveride the onpaint event.
And put something like this...

Dim P1 as new pen(color.black,1)
tyy8Author Commented:
Thanks everyone. The line control is in the VB6.0 toolbox - I just can't imagine why they got rid of it in .NET
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.