none
how can i make a substring to bold in string without ant control in C#\VB.net RRS feed

  • Question

  • i want to make a substring to bold in a main string without any control in a form in vb\c#.net.
    For. eg.
     "I am RK. Back to RK"
    Here i want to make "Back" to font bold without any control on a form.
    How can i do it..?
    Thanks.
    Friday, November 23, 2012 6:06 AM

All replies

  • This is an online forum provided by Microsoft about their product "Microsoft Project".  You'll have better luck with your question if you re-post in a more appropriate forum. See http://www.microsoft.com/communities/forums/default.mspx or search via Google and/or Bing. 

    --rms www.rmschneider.com

    Friday, November 23, 2012 7:08 AM
  • Hi you use to linq ,

    for examle ;

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    namespace WebApplication1
    {
        public class Items
        {

            public string Text { get; set; }
        }

        public partial class Default : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                string Content = "I am RK. Back to RK";
                List<Items> sList = new List<Items>();
                string[] cList = Content.Split(' ');
                foreach (var item in cList)
                {
                    Items I = new Items
                    {
                        Text = item
                    };
                    sList.Add(I);
                }
                string BoldText = "Back";
                foreach (Items replaced in sList)
                {
                    if (replaced.Text == BoldText)
                    {
                        Items item = sList.Find(row => row.Text == "Back");
                        if (item != null)
                        {
                            item.Text = replaced.Text.Replace(BoldText, "<b>" + BoldText + "</b>");
                        }
                    }
                    Response.Write(replaced.Text + "<br>");
                }

            }
        }
    }

    here is the result  on asp.net

    example

    Monday, November 26, 2012 10:15 AM