Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
230
Highlight text in grid
posted

Hi ,

I m in need of highlighting a word or phrase in Ultrawingrid. Is it possible to do this. Currently I m using NetAdvantage for .NET 2007 Vol. 3 CLR 2.0.

 

Parents
No Data
Reply
  • 12333
    posted

    Hi there,

    Try this code to see if it does what you are looking for:

    /// <summary>

    /// Finds the phrase.

    /// </summary>

    /// <param name="g">The WinGrid reference.</param>

    /// <param name="s">The string you want to look for.</param>

    public static void FindPhrase(UltraGrid g, String s)

    {

    foreach (UltraGridRow r in g.Rows)

    {

    foreach (UltraGridCell c in r.Cells)

    {

    if (c.Text.Contains(s))

    {

    c.Activate(); //The Cell must be activated first

    g.PerformAction(UltraGridAction.EnterEditMode); //Cell must be in Edit mode to perform a selection

    c.SelStart = c.Text.IndexOf(s); //Start the Selection

    c.SelLength = s.Length; //for this length

    g.DisplayLayout.RowScrollRegions[0].FirstRow = r; //for eye candy, make this the first visible row

    return;

    }

    }

    }

    }

Children