.NET

Reply
Active Contributor
38 Posts
0 Kudos
Registered: ‎09-08-2006
Post 11 of 13

Re: RBG value from color dialog

10-03-2006 01:29 PM in reply to: Littlerubarbwk
I got it to work this is the code I ended up using for now..

Dim CD As New Autodesk.AutoCAD.Windows.ColorDialog()
Dim C As Autodesk.AutoCAD.Colors.Color = Autodesk.AutoCAD.Colors.Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMethod.ByAci, 1) 'Set color to RED
Dim PENN As Object
Dim r As Integer
Dim g As Integer
Dim b As Integer
CD.Color = C
CD.SetDialogTabs(Autodesk.AutoCAD.Windows.ColorDialog.ColorTabs.ACITab Xor Autodesk.AutoCAD.Windows.ColorDialog.ColorTabs.ColorBookTab)
If CD.ShowDialog <> Windows.Forms.DialogResult.OK Then
End If
PENN = CD.Color.ToString
r = CD.Color.ColorValue.R.ToString
g = CD.Color.ColorValue.G.ToString
b = CD.Color.ColorValue.B.ToString
PictureBox1.BackColor = System.Drawing.Color.FromArgb(r, g, b)
TextBox2.Text = PENN


I tried combiing the RGB value and couldn't get it to work do you see anything that's missing

Dim swatch As String

swatch = CD.Color.ColorValue.R.ToString + "," + CD.Color.ColorValue.G.ToString + "," + CD.Color.ColorValue.B.ToString

PictureBox1.BackColor = System.Drawing.Color.FromArgb(swatch) Message was edited by: Littlerubarbwk
Distinguished Contributor
125 Posts
0 Kudos
Registered: ‎08-02-2005
Post 12 of 13

Re: RBG value from color dialog

10-04-2006 10:54 AM in reply to: Littlerubarbwk
You can use CD.Color.ColorValue directly as a system.color
like so:

Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim CD As New Autodesk.AutoCAD.Windows.ColorDialog
CD.Color = Autodesk.AutoCAD.Colors.Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMetho d.ByAci, 1) 'Set Color to Red
CD.SetDialogTabs(Autodesk.AutoCAD.Windows.ColorDialog.ColorTabs.ACITab)
Dim dr As DialogResult = CD.ShowDialog 'Show the Dialog
If dr = DialogResult.OK Then 'If user clicked OK then
PictureBox1.BackColor = CD.Color.ColorValue 'Set the backcolor to the color selected
End If
End Sub
Active Contributor
38 Posts
0 Kudos
Registered: ‎09-08-2006
Post 13 of 13

Re: RBG value from color dialog

10-04-2006 11:32 AM in reply to: Littlerubarbwk
Thanks it works
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!