|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Line across formMike L wrote:
> 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
Show quote
Hide quote
"Chris" <no@spam.com> schrieb: 'Pen' objects should be disposed if they are not needed any more. It's >> 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) better to store the 'Pen' object in a private variable, for example, instead of creating a new pen every time the form is drawn. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Herfried K. Wagner [MVP] wrote:
Show quoteHide quote > "Chris" <no@spam.com> schrieb: Thanks for the info. If I use the same pen for the life of the form > >>> 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) > > > '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. > 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
Show quote
Hide quote
"Chris" <no@spam.com> schrieb: You may want to call the pen's 'Dispose' method in the form's overridden >>> 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) >> >> >> '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. >> > > 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? 'Dispose' method. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> "Mike L" <Cadel@nospam.nospam> schrieb
http://msdn.microsoft.com/library/en-us/cpguide/html/_gdiplus_drawing_a_line_usecsharp.asp
> In VB.NET Windows Form, how do I add a line across the form? (same via <F1>) Armin Hi,
A line and shape control I created. www.windowsformsdatagridhelp.info/downloads/shapedemo.zip Ken ----------------- "Mike L" <Cadel@nospam.nospam> wrote in message In VB.NET Windows Form, how do I add a line across the form?news:2B5A7051-B557-4FA3-928E-BB6907A00F4D@microsoft.com... "Mike L" <Cadel@nospam.nospam> schrieb: Shapes and lines:> In VB.NET Windows Form, how do I add a line across the form? 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-ab57acd8ea01/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. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> 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. Show quoteHide quote "Herfried K. Wagner [MVP]" wrote: > "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-ab57acd8ea01/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. > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://classicvb.org/petition/> > > |
|||||||||||||||||||||||