如何在c#中更改按钮颜色

Nee*_*raj 0 c# background-color

我在DataGrid中有很多按钮

我想将Button的颜色设置为绿色而Button.Text变为白色(不是全部,仅适用于1个按钮),基于我的if条件,我使用ITextSharp来创建PDF生成,我评论了iTextSharp头文件,我得到了结果但我必须在我的代码中需要iTextSharp这次发生错误发生.

"无法隐式转换类型iTextSharp.text.Color到System.Drawing.Color"

这是我的iTextSharp头文件

using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.html;
Run Code Online (Sandbox Code Playgroud)

这是代码

            if (dsRecAdj.Tables[2].Rows.Count > 0)
                {

                    Button btn = (Button)e.Row.FindControl("btnSalvage");
                    btn.ForeColor = Color.Red;

                }
Run Code Online (Sandbox Code Playgroud)

有些人请帮助我

Ste*_*tty 5

您正在引用ColoriTextSharp.text命名空间中的类型.尝试明确指定命名空间:

btn.ForeColor = System.Drawing.Color.Red;
Run Code Online (Sandbox Code Playgroud)