Windows Develop Bookmark and Share   
 index > Windows Forms General > How to change the color or format of the text displayed on Label control?
 

How to change the color or format of the text displayed on Label control?

HI,


In my application i am displaying some text on Label at runtime. I nedd to change the color and format type(bold) for some text only.

How to do this?
MadhuSudhan Reddy Pulimi  Monday, March 03, 2008 11:04 AM

Code for Changing the FONT:

------------------------------------------

this.label4.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

Code for Changing the FORECOLOR:

------------------------------------------------------

this.label4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));

Hope this helps!!

MeetJayBlack  Monday, March 03, 2008 8:00 PM

I think I misunderstood your issue. If you are looking for changing format of only a PORTION of the text in the LABEL control then I guess it's not possible as LABEL control applies the format to the whole text while painting itself. You might give it a try by creating a Custom Control and handling the Paint on your own there by decide the format of the text accoding to your requirements.
MeetJayBlack  Monday, March 03, 2008 8:14 PM

Code for Changing the FONT:

------------------------------------------

this.label4.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

Code for Changing the FORECOLOR:

------------------------------------------------------

this.label4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));

Hope this helps!!

MeetJayBlack  Monday, March 03, 2008 8:00 PM

I think I misunderstood your issue. If you are looking for changing format of only a PORTION of the text in the LABEL control then I guess it's not possible as LABEL control applies the format to the whole text while painting itself. You might give it a try by creating a Custom Control and handling the Paint on your own there by decide the format of the text accoding to your requirements.
MeetJayBlack  Monday, March 03, 2008 8:14 PM

You can use google to search for other answers

Custom Search

More Threads

• Multiple forms?
• General windows forms design question...
• Update and Delete Cascading
• opengl with CLR
• Crop a circle image from a square picture
• How to assign Empty Value to DateTimePicker?
• TreeView label editing preempted after single character
• adding tree node
• User.config and app.exe.config
• WebBrowser interaction help