简体   繁体   中英

How to change Background color of TextBox?

I am working on WPF, I want to change Background---color of textbox ( txtStatus.Background= white), but it is giving ERROR. Here my code is:

public Window2()
            {
                InitializeComponent();
                txtStatus.Text = "Current Operation: NULL";
                txtStatus.Background= white
            }

You need to use Brushes :

txtStatus.Foreground = Brushes.White;

It contains a lot of colors, though if you want to use aRGB values then you can do it like this:

txtStatus.Foreground = new SolidBrush(Color.FromArgb(255, 0, 0, 255));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM