# Dialogs.SetCustomColorDialog examples

Examples for [SetCustomColorDialog](https://developer.rhino3d.com/api/rhinocommon/type/rhino.ui.dialogs/setcustomcolordialog.md) in Rhino.UI.Dialogs.

## C#

```cs
using Rhino;
using Rhino.Commands;
using Rhino.UI;
using System.Windows.Forms;

namespace examples_cs
{
  public class ReplaceColorDialogCommand : Command
  {
    public override string EnglishName { get { return "csReplaceColorDialog"; } }

    private ColorDialog m_dlg = null;

    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      Dialogs.SetCustomColorDialog(OnSetCustomColorDialog);
      return Result.Success;
    }

    void OnSetCustomColorDialog(object sender, GetColorEventArgs e)
    {
      m_dlg = new ColorDialog();
      if (m_dlg.ShowDialog(null) == DialogResult.OK)
      {
        var c = m_dlg.Color;
        e.SelectedColor = c;
      }
    }
  }
}
```

## Python

```py
from Rhino import *
from Rhino.Commands import *
from Rhino.UI import *
from System.Windows.Forms import *

m_dlg = None

def RunCommand():
  Dialogs.SetCustomColorDialog(OnSetCustomColorDialog)
  return Result.Success

def OnSetCustomColorDialog(sender, e):
  m_dlg = ColorDialog()
  if m_dlg.ShowDialog(None) == DialogResult.OK:
    c = m_dlg.Color
    e.SelectedColor = c

if __name__ == "__main__":
  RunCommand()
```

## VB.NET

```vbnet
Imports Rhino
Imports Rhino.Commands
Imports Rhino.UI
Imports System.Windows.Forms

Namespace examples_vb
  Public Class ReplaceColorDialogCommand
    Inherits Command
    Public Overrides ReadOnly Property EnglishName() As String
      Get
        Return "vbReplaceColorDialog"
      End Get
    End Property

    Private m_dlg As ColorDialog = Nothing

    Protected Overrides Function RunCommand(doc As RhinoDoc, mode As RunMode) As Result
      Dialogs.SetCustomColorDialog(AddressOf OnSetCustomColorDialog)
      Return Result.Success
    End Function

    Private Sub OnSetCustomColorDialog(sender As Object, e As GetColorEventArgs)

      m_dlg = New ColorDialog()
      If m_dlg.ShowDialog(Nothing) = DialogResult.OK Then
        Dim c = m_dlg.Color
        e.SelectedColor = c
      End If
    End Sub
  End Class
End Namespace
```
