# Change color Message in Component.Message?

**URL:** <https://discourse.mcneel.com/t/change-color-message-in-component-message/144638>\
**Category:** Grasshopper\
**Tags:** windows, visualstudio, csharp\
**Created:** [June 29, 2022, 6:59pm UTC](https://discourse.mcneel.com/t/change-color-message-in-component-message/144638 "2022-06-29T18:59:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rh-3d-p](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/rh-3d-p/32/485582_2.png) [@Rh-3d-p](https://discourse.mcneel.com/u/Rh-3d-p)\
**Post date:** [June 29, 2022, 6:59pm UTC](https://discourse.mcneel.com/t/change-color-message-in-component-message/144638/1 "2022-06-29T18:59:27Z")

</div>

Hello, how does the background color of this part of the messag change?  
`Component.Message="";`

in VisualStodio Or c# Componenet?  
 ![color](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/f/7/2/f72e7afd01e5dc850475ee42da14f22fc4045621.jpeg)

---

<div class="post-metadata">

**Author:** ![hiron](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/hiron/32/702571_2.png) [@hiron](https://discourse.mcneel.com/u/hiron)\
**Post date:** [February 4, 2024, 1:15pm UTC](https://discourse.mcneel.com/t/change-color-message-in-component-message/144638/2 "2024-02-04T13:15:42Z")

</div>

I was also curious about this, but it seems that the color is determined by following method and cannot be specified directly by the user.

The first argument (`style.Edge`) is the color of the component’s edges, and the contrast against it seems to determine the text color.

```auto
public static Color ForegroundColour(
	style.Edge, 200
)

```

> **[GH\_GraphicsUtil.ForegroundColour Method](https://developer.rhino3d.com/api/grasshopper/html/M_Grasshopper_GUI_GH_GraphicsUtil_ForegroundColour.htm)**
>
> Calculates a suitable foreground color. If the background is lighter than 50%, the foreground will be darker, otherwise the foreground will be lighter.

---

<div class="post-metadata">

**Author:** ![DavidRutten](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/davidrutten/32/755688_2.png) [@DavidRutten](https://discourse.mcneel.com/u/DavidRutten)\
**Post date:** [February 4, 2024, 8:10pm UTC](https://discourse.mcneel.com/t/change-color-message-in-component-message/144638/3 "2024-02-04T20:10:05Z")

</div>

Correct, the colour of the label is identical to the colour of the capsule edge.

---

<div class="post-metadata">

**Author:** ![Rh-3d-p](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/rh-3d-p/32/485582_2.png) [@Rh-3d-p](https://discourse.mcneel.com/u/Rh-3d-p)\
**Post date:** [February 6, 2024, 4:10am UTC](https://discourse.mcneel.com/t/change-color-message-in-component-message/144638/4 "2024-02-06T04:10:00Z")

</div>

> [@Rh-3d-p](#):
>
> Component.Message=“”;

Hi, I’m testing but still not changing the color!

 ![color](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/3/f/6/3f67f0a5283b787e26c1875f98db6b4deea1addf.jpeg)

```auto
 
  public void ForegroundColour(Color color, int size)
    {
        // Your implementation here (currently missing in your code)
    }
  private void RunScript(Color color, ref object a)
  {
      Component.Message = "Test";
        ForegroundColour(color, 50);
    a = null;
  }
}

```

[Color M.gh](https://discourse.mcneel.com/uploads/short-url/fc2Q9vX8ESnfs1Ze8H6EanBibAT.gh) (8.9 KB)

---

<div class="post-metadata">

**Author:** ![hiron](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/hiron/32/702571_2.png) [@hiron](https://discourse.mcneel.com/u/hiron)\
**Post date:** [February 6, 2024, 5:59am UTC](https://discourse.mcneel.com/t/change-color-message-in-component-message/144638/5 "2024-02-06T05:59:20Z")

</div>

I was referring to Grasshopper’s “internal” implementation.  
So if you want to change the color of a message, you can only do so as a side effect by changing the color of the capsule’s edges.

It cannot be changed directly using the method `ForegroundColour`.

The following page provides a sample of how to change the edge color of the capsule, but it is not possible to do so from the C# Script component.

> [@Change the color of the Custom component](https://discourse.mcneel.com/t/change-the-color-of-the-custom-component/56435):
>
> Hi @DavidRutten Basically, as stated in the Title - I would like to change the main color of my Custom components (non-editable) It would be easier to navigate inside the Canvas. See below: [image]

---

<div class="post-metadata">

**Author:** ![DavidRutten](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/davidrutten/32/755688_2.png) [@DavidRutten](https://discourse.mcneel.com/u/DavidRutten)\
**Post date:** [February 6, 2024, 9:06am UTC](https://discourse.mcneel.com/t/change-color-message-in-component-message/144638/6 "2024-02-06T09:06:10Z")

</div>

Yeah, sounds like you’ll have to draw those labels yourself from scratch from your attributes.
