473,326 Members | 2,438 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Line across form

In VB.NET Windows Form, how do I add a line across the form?
Nov 21 '05 #1
8 1327
Mike 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
Nov 21 '05 #2
"Mike L" <Ca***@nospam.nospam> schrieb
In VB.NET Windows Form, how do I add a line across the form?


http://msdn.microsoft.com/library/en..._usecsharp.asp

(same via <F1>)

Armin

Nov 21 '05 #3
"Chris" <no@spam.com> schrieb:
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.

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

Nov 21 '05 #4
Hi,

A line and shape control I created.

http://www.windowsformsdatagridhelp..../shapedemo.zip

Ken
-----------------
"Mike L" <Ca***@nospam.nospam> wrote in message
news:2B**********************************@microsof t.com...
In VB.NET Windows Form, how do I add a line across the form?
Nov 21 '05 #5
"Mike L" <Ca***@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/>

Nov 21 '05 #6
Herfried K. Wagner [MVP] wrote:
"Chris" <no@spam.com> schrieb:
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.


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
Nov 21 '05 #7
"Chris" <no@spam.com> schrieb:
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?


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

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

Nov 21 '05 #8
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.

"Herfried K. Wagner [MVP]" wrote:
"Mike L" <Ca***@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/>

Nov 21 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Cordula's Web | last post by:
Hello, here's a strange bug (?) I've came across (using Python 2.2): # loop_1 for line in file: if some_condition(line): break do_something() # loop_2
4
by: Jeff Thies | last post by:
It seems that there can be too many words on a line. This is a problem with pages that are not fixed width. There seems to be a few problems. 1) Finding where the next line starts after...
0
by: dtSearch | last post by:
Press Contact: Belinda Banks S&S Public Relations (212) 946-2823 Belinda@sspr.com Announcing New dtSearch® Product Line Version Release Adds Broader Spider Capabilities to dtSearch Desktop,...
1
by: news | last post by:
Hi all, How do you implement alternate line colors in ms access datasheet view Regards Joe --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system...
4
by: lasmit | last post by:
I am updating a C# web project which stores the contents of an ASP web form in an SQL Server 2000 database. Originally the code deleted all the current contents of the database and then...
9
by: McGeeky | last post by:
Is there a way to get a user control to remember its state across pages? I have a standard page layout I use with a header and footer as user controls. Each page uses the same layout by means of...
1
by: Scott H. | last post by:
Hello: I am trying to use Crystal Reports from VS.NET 2003 to produce a simple line chart, where the x axis represents the number of measurements taken and the y axis represents the range of...
4
by: =?Utf-8?B?RmFyaWJh?= | last post by:
It know that we can use the following method http://msdn2.microsoft.com/en-us/library/eb0zx8fc.aspx to form authenticate across multiple applications. I have created an asp.net application...
12
by: Dom | last post by:
VB had a "line" control, just a simple line that let you separate controls without the wasted space of a Groupbox. Did CSharp drop this? Dom
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.