|
-
Mar 28th, 2007, 11:18 AM
#1
Thread Starter
Junior Member
Pen color selection
Hey everyone!!
Just a quick question.
I've drawn about 3 lines on form using pen.
line1 pen1
line2 pen2
line3 pen3
On the form i've put a menustrip to enable users to select different colors for each line. How do i code this in vb.net 2005.
Thank you
-
Mar 28th, 2007, 11:31 AM
#2
Re: Pen color selection
Do want like a color Dialog, or random colors ¿
VB.NET MVP 2008 - Present
-
Mar 28th, 2007, 11:43 AM
#3
Thread Starter
Junior Member
Re: Pen color selection
Like a color dialog HanneSThEGreaT
-
Mar 28th, 2007, 11:51 AM
#4
Re: Pen color selection
OK, Then you can do something like :
Code:
Private cColor As Color 'Selected Color To Draw With
'Create A New ColorDialog Object
Dim CColorD As New ColorDialog
'Settings For CColorD
'Open Full Dialog Box
CColorD.FullOpen = True
'Do Not Display Help Button On TitleBar
CColorD.ShowHelp = False
'Display All Available Colors
CColorD.AnyColor = True
'If OK Is Selected On The Color DialogBox
If (CColorD.ShowDialog() = System.Windows.Forms.DialogResult.OK) Then
'Change The Selection Color To The User Specified Color.
cColor = CColorD.Color
Else
'Cancel Was Clicked, return To default
cColor = System.Drawing.Color.Black
End If
I've declared the cColor variable as a modular variable, you can of course make it Public / or local (Dim)
Then draw the line, here's an example :
Code:
Dim pLinePen As New Pen(cColor, 1) 'you can use whatever width, I've used 1
e.Graphics.DrawLine(pLinePen, sStartX, sStartY, sEndX, sEndY)
I hope it helps!
VB.NET MVP 2008 - Present
-
Mar 28th, 2007, 11:54 AM
#5
Thread Starter
Junior Member
Re: Pen color selection
Thanks HanneSThEGreaT, i'll try this just now, it looks quite logical and i don't see why it wouldn't work.
Once again, Thanks Man!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|