This is a migrated thread and some comments may be shown as answers.

Conditional Row Formatting

3 Answers 95 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Terry
Top achievements
Rank 1
Terry asked on 03 May 2012, 11:02 AM
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

Terry

3 Answers, 1 is accepted

Sort by
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 03 May 2012, 11:53 AM
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)
        {
            return;
        }
 
        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
Thanks
Richard
0
Krishna
Top achievements
Rank 1
answered on 03 May 2012, 01:04 PM
i need custom masking in winrad grid, like email address mask,allow 2 space and allow 3 hypen
0
Boryana
Telerik team
answered on 07 May 2012, 02:25 PM
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 http://www.telerik.com/community/forums/winforms/gridview/important-information-on-using-the-telerik-forums.aspx.

Thank you for your cooperation.

All the best,
Boryana
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
GridView
Asked by
Terry
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Krishna
Top achievements
Rank 1
Boryana
Telerik team
Share this question
or