TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

<< Back to C-SHARP

ForeColor, BackColor: Windows Forms

ForeColor, BackColor. Windows Forms can have colors. The ForeColor property adjusts the text color and some borders on controls. The BackColor property meanwhile adjusts the background of controls. These two properties are available on many control instances.
ForeColor. ForeColor changes the color of controls. In Windows Forms, many controls have this property as well as a BackColor property. The ForeColor property typically adjusts the text color. It adjusts the border on buttons.
To begin, you can add a Button control to your Windows Forms project by double-clicking on the Button element in the Toolbox. Next, right-click on the button and select Properties. After this, please scroll down to the ForeColor entry.

Tip: In Visual Studio, you can set the default ForeColor for the control. During execution, you can adjust the ForeColor with C# code.

In the example screenshot, the ForeColor was set to red. Because the control is a Button control, the border also changed to red. This varies depending on what visual appearance is enabled for Windows.

Note: You will just have to try and see how a control looks after setting ForeColor.

The ForeColor property is a perfect complement to the BackColor property in Windows Forms. Please remember that if you adjust the ForeColor, you should adjust the BackColor so the text can be read.

Also: By using the system defaults or other system colors, you can ensure readability in more cases.

BackColor. BackColor refers to background color. The BackColor property in Windows Forms gives you the ability to change the background color of a window or other control. Foreground colors, and nested objects in the form, will not be affected.
Please create a new Windows Forms project and then right-click on the control or form itself. Select properties, and then scroll to BackColor. You can change the BackColor using the user interface in Visual Studio.

Tip: For many projects, using a system-dependent color is best. It will coordinate with other system colors.

You can also modify the BackColor property in the C# code of your project. Please assign the property "this.BackColor" to a Color instance. Also, other controls, not just forms, have BackColor properties that are equivalent in meaning.

Tip: The BackColor property in Windows Forms provides a mechanism for mutating the background color of a window or control.

Typically: Using a system value for the background is best, as it will ensure that foreground elements are visible upon the background.

Summary. We examined the ForeColor and BackColor properties in Windows Forms. When you set one of these properties, it is often a good idea to set the other. This prevents illegible combinations: white text on a white background, for example.
© TheDeveloperBlog.com
Home
The Dev Codes

Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf