Active Contributor
Posts: 38
Registered: ‎09-08-2006
Message 11 of 13 (152 Views)

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
Posts: 125
Registered: ‎08-02-2005
Message 12 of 13 (152 Views)

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
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
Posts: 38
Registered: ‎09-08-2006
Message 13 of 13 (152 Views)

Re: RBG value from color dialog

10-04-2006 11:32 AM in reply to: Littlerubarbwk
Thanks it works
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.