Conditional Row Formatting

4 posts, 1 answers
  1. Terry
    Terry avatar
    39 posts
    Member since:
    Sep 2007

    Posted 03 May 2012 Link to this post

    Hi Guys,

    I'm trying to set a thicker and coloured row line based on a value in the row (group). I've attached an image of what I'm trying to achieve.
    Would any of you know be able to point me in the right direction for what I'm sure is a simple enough solution.

    Many thanks

  2. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 03 May 2012 Link to this post

    Hi Terry, 

    The best way in my view to do this would not be via RowFormatting but via RowPaint
    You can learn more about RowPaint in this area of the docs

    Here would be an example of painting a line on the top of a row that has an Id of 2

    this.radGridView1.RowPaint += new GridViewRowPaintEventHandler(radGridView1_RowPaint);

    private void radGridView1_RowPaint(object sender, GridViewRowPaintEventArgs e)
        GridDataRowElement dataRow = e.Row as GridDataRowElement;
        if (dataRow != null)
            int value = (int)dataRow.RowInfo.Cells["Id"].Value;
            if (value != 2)
            Pen pen = Pens.RoyalBlue;
            Size rowSize = dataRow.Size;
            rowSize.Height -= 3;
            e.Graphics.DrawLine(pen, e.Row.Location.X, e.Row.Location.Y, e.Row.Location.X + rowSize.Width, e.Row.Location.Y);

    If this helps, please remember to mark as answer. If you need further help, please let me know
  3. DevCraft R3 2016 release webinar banner
  4. Krishna
    Krishna avatar
    1 posts
    Member since:
    May 2012

    Posted 03 May 2012 Link to this post

    i need custom masking in winrad grid, like email address mask,allow 2 space and allow 3 hypen
  5. Boryana
    Boryana avatar
    330 posts

    Posted 07 May 2012 Link to this post

    Hello Krishna,

    Since your post is not related to the initial topic, I kindly ask you to open a new forum thread. For more information on using our Forums, please refer to

    Thank you for your cooperation.

    All the best,
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Back to Top