Can I change the color on the portion of the following string represented by m_pwd
and m_senior
?
string m_pwd = "PWD";
string m_senior = "Senior";
lblMarquee.Text = "Hi" + m_senior + "and" + m_pwd;
You cannot change the "color" of a string, just like you can't change the color of a number or a list or any other data type that simply stores values.
What you need to do is to modify the visual representation of that data, in this case the Label
control. Anything deriving from Control
has an available ForeColor
and BackColor
property.
An easy way to do what you need in WinForms is to group several Labels next to each other in a Panel
, change colors on each as desired, and then manipulate the Panel
as a single entity as necessary.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments