Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / June 2005

Tip: Looking for answers? Try searching our database.

Line across form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mike L - 28 Jun 2005 20:22 GMT
In VB.NET Windows Form, how do I add a line across the form?
Chris - 28 Jun 2005 20:35 GMT
> In VB.NET Windows Form, how do I add a line across the form?

I did this inside of the forms paint method.  Hope it helps.

Chris

Private Sub Main_Paint(ByVal sender As Object, ByVal e As            
System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint

        Dim Pen As New Pen(Color.MediumBlue, 2)
        Dim TopLine As Integer = 150
        Dim BottomLine As Integer = 388
        e.Graphics.DrawLine(Pen, 0, TopLine, 640, TopLine)

End Sub
Herfried K. Wagner [MVP] - 28 Jun 2005 21:55 GMT
"Chris" <no@spam.com> schrieb:
>> In VB.NET Windows Form, how do I add a line across the form?
>
[quoted text clipped - 9 lines]
>         Dim BottomLine As Integer = 388
>         e.Graphics.DrawLine(Pen, 0, TopLine, 640, TopLine)

'Pen' objects should be disposed if they are not needed any more.  It's
better to store the 'Pen' object in a private variable, for example, instead
of creating a new pen every time the form is drawn.

Signature

M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>

Chris - 29 Jun 2005 16:11 GMT
> "Chris" <no@spam.com> schrieb:
>
[quoted text clipped - 15 lines]
> better to store the 'Pen' object in a private variable, for example,
> instead of creating a new pen every time the form is drawn.

Thanks for the info.  If I use the same pen for the life of the form
should I still dispose of it when the form is closed, or will the
auto-disposing of the form take care of it for me?

chris
Herfried K. Wagner [MVP] - 29 Jun 2005 16:43 GMT
"Chris" <no@spam.com> schrieb:
>>> Private Sub Main_Paint(ByVal sender As Object, ByVal e As
>>> System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
[quoted text clipped - 11 lines]
> should I still dispose of it when the form is closed, or will the
> auto-disposing of the form take care of it for me?

You may want to call the pen's 'Dispose' method in the form's overridden
'Dispose' method.

Signature

M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>

Armin Zingler - 28 Jun 2005 20:40 GMT
> In VB.NET Windows Form, how do I add a line across the form?

http://msdn.microsoft.com/library/en-us/cpguide/html/_gdiplus_drawing_a_line_use
csharp.asp


(same via <F1>)

Armin
Ken Tucker [MVP] - 29 Jun 2005 01:56 GMT
Hi,

       A line and shape control I created.

www.windowsformsdatagridhelp.info/downloads/shapedemo.zip

Ken
-----------------
In VB.NET Windows Form, how do I add a line across the form?
Herfried K. Wagner [MVP] - 29 Jun 2005 09:39 GMT
"Mike L" <Cadel@nospam.nospam> schrieb:
> In VB.NET Windows Form, how do I add a line across the form?

Shapes and lines:

Advanced Shape Control
<URL:http://www.codeproject.com/vb/net/advanced_shape_control.asp>

LineControls.exe
<URL:http://www.gotdotnet.com/team/vb/LineControls.exe>
<URL:http://download.microsoft.com/download/7/e/0/7e070297-47fe-4443-9194-ab57acd8ea0
1/LineControls.msi
>

Creating transparent Windows Forms controls.
<URL:http://www.bobpowell.net/transcontrols.htm>

Rules:

Wrapping Win32 Controls in .NET - Horizontal and Vertical Rules
<URL:http://www.codeproject.com/cs/miscctrl/hvrules1.asp>

Alternatively you can use a label control with width or height set to 2, and
'BorderStyle' set to 'Fixed3D' to create an inset line.

Signature

M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>

Mike L - 30 Jun 2005 22:00 GMT
Your answer worked best, I used the simple label control, set it to black and
resized using the mouse.  Did it in less than a second and I didn't have to
write one line of code.  Thank you.

> "Mike L" <Cadel@nospam.nospam> schrieb:
> > In VB.NET Windows Form, how do I add a line across the form?
[quoted text clipped - 18 lines]
> Alternatively you can use a label control with width or height set to 2, and
> 'BorderStyle' set to 'Fixed3D' to create an inset line.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.