c# .net Adsense ADO.NET Linq Viruses/security asp.net MVC JQuery Angular-js Node-js SEO Java C++ SQL API Networking vb.net .Net Css JavaScript Generics c#.Net entity framework HTML Website host Website Construction Guide HTTP tutorial W3C tutorial Web Services JSON Psychology Ionic framework Angular ReactJS Python Computer Android
c# .net

How to set background for text using Graphics.DrawRectangle in c#?

| | ASP-NET , CSharp , MVC

In this tutorial I will show you how to set background for text using Graphics.DrawRectangle in c#.

C# CODE FOR TEXT & BACKGROUND:

   //background added
   Brush brs = new SolidBrush(Color.Red);
   System.Drawing.SizeF stringSize = graphics.MeasureString(text, font);
   graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, stringSize.Width, stringSize.Height);
   graphics.DrawString(text, font, brs, 0, 0);

OUTPUT:

Set background for text using c#

VIDEO TUTORIAL SET BACKGROUND IN ASP.NET MVC C#:
This video demonstrates how to convert text to image and also set background color and font color using asp.net c#.