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

Telerik GridView

1 Answer 76 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dipankar
Top achievements
Rank 1
Dipankar asked on 19 Nov 2012, 01:54 PM
I have radgridview with data written in design time i.e, code
this.radGridView1.Rows.Add("Jjkh", 19, 2, 9, 12, 21,52, 44, 63,56, System.DateTime.Now);
            this.radGridView1.Rows.Add("Jjkh", 10, 2, 9, 12, 21, 52, 44, 63, 87, System.DateTime.Now);
            this.radGridView1.Rows.Add("eur", 16, 2, 9, 12, 21, 52, 44, 63, 34, System.DateTime.Now);
            this.radGridView1.Rows.Add("usd", 14, 2, 9, 12, 21, 52, 44, 63, 23, System.DateTime.Now);
            this.radGridView1.Rows.Add("Jjkh", 67, 81, 33, 4, 55, 66, 7, 7, 11, System.DateTime.Now);
After this i've written code for forecolor:
for (int i = 0; i < radGridView1.Rows.Count; i++)
            {
                for (int j = 1; j < 4; j++)
                    this.radGridView1.Rows[i].Cells[j].Style.ForeColor = System.Drawing.Color.White;
                this.radGridView1.Rows[i].Cells[4].Style.ForeColor = System.Drawing.Color.Blue;
                this.radGridView1.Rows[i].Cells[5].Style.ForeColor = System.Drawing.Color.Red;

            }
But for back color, i've written in radGridView1_CellFormatting,
e.CellElement.BackColor = Color.Blue;
But the event radGridView1_CellFormatting is not binding with any method..

1 Answer, 1 is accepted

Sort by
0
Anton
Telerik team
answered on 21 Nov 2012, 02:05 PM
Hi Dipankar,

Thank you for writing.

I assume that you want to attach the CellFormating event to RadGridView. If so, here is how you can do that:

public Form1()
{
    InitializeComponent();
    this.radGridView1.CellFormatting += new CellFormattingEventHandler(radGridView1_CellFormatting);
}
void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
{
    e.CellElement.DrawFill = true;
    e.CellElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
    e.CellElement.BackColor = Color.Blue;
}

You can find more information about events and how to use them in various resources on the internet, for example:
http://www.dotnetperls.com/event
http://msdn.microsoft.com/en-us/library/aa645739%28v=vs.71%29.aspx

Should you have any other questions, I will be glad to assist you.

Kind regards,
Anton
the Telerik team
Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
Tags
GridView
Asked by
Dipankar
Top achievements
Rank 1
Answers by
Anton
Telerik team
Share this question
or