Button background colour

前端 未结 6 1532

I need to change the background colour of a button using C# code (Visual Studio 2008).

I saw some people recommending the inclusion of a directive: us

6条回答
  •  遥遥无期
    2021-01-21 13:01

    This should change your button background color to Red

    yourButtonName.BackColor = Color.Red;
    

    You need to include System.Drawing namespace as Color class belongs to that. Like this

    using System.Drawing;
    

    And ofcourse you need to add the reference to System.Drawing DLL in your project to use this namespace and Color class.

    enter image description here

提交回复
热议问题