UI Design

Posted on 2006-04-12
Last Modified: 2010-04-23
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)
Question by:tyy8
    LVL 2

    Expert Comment

    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!

    LVL 2

    Expert Comment

    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.

    LVL 85

    Accepted Solution

    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...

    Expert Comment

    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(,1),me.height/2,me.right,me.height/2)

    Author Comment

    Thanks everyone. The line control is in the VB6.0 toolbox - I just can't imagine why they got rid of it in .NET

    Featured Post

    Gigs: Get Your Project Delivered by an Expert

    Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

    Join & Write a Comment

    It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now