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

cell backcolor change after scroll

2 Answers 18 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tomasz
Top achievements
Rank 1
Tomasz asked on 07 Jan 2014, 08:41 AM
Hallo,
It is my first post so Hallo!

I have a problem with radgridview.

Here is my sample code:
private void radGridView1_CellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
 {
            if (e.CellElement.RowInfo.Cells["io_time_sec"].Value != null)
                {
                    Int64 lTime = Convert.ToInt64(e.CellElement.RowInfo.Cells["io_time_sec"].Value);
                    Int16 nStat = Convert.ToInt16(e.CellElement.RowInfo.Cells["io_state"].Value);
 
                    if ((lTime <= 0) || (lTime >= 36000)) {
                        e.CellElement.DrawText = true;
                        e.CellElement.ForeColor = Color.Red;
                        e.CellElement.NumberOfColors = 1;
                        e.CellElement.GradientStyle = GradientStyles.Solid;
 
                    } else {
                        e.CellElement.DrawText = true;
                        e.CellElement.ForeColor = Color.Black;
                        e.CellElement.NumberOfColors = 1;
                        e.CellElement.GradientStyle = GradientStyles.Solid;
                    }
               }
}

Now I want to select the cell where I made ​​the changes.

void dgvView_Changed(object sender, CorrectDateTimeEvents e)
        {
            if (e.en == CorrectDataEventsEnum.Evt_Cancel)
            {
                winform.Close();
            }
 
            if (e.en == CorrectDataEventsEnum.Evt_OK)
            {
                radGridView1.CurrentRow.Cells["io_datein"].Value = e.valueDateIn;
                radGridView1.CurrentRow.Cells["io_dateout"].Value = e.valueDateOut;
 
                radGridView1.CurrentCell.DrawFill = true;
                radGridView1.CurrentCell.BackColor = Color.BlueViolet;
                radGridView1.CurrentCell.NumberOfColors = 1;
                radGridView1.CurrentCell.GradientStyle = GradientStyles.Solid;
                 
                winform.Close();
 
            }
        }

Everything works fine, but after I use the scrol color changes position and jumps to a random record or cell.

What am I doing wrong?



2 Answers, 1 is accepted

Sort by
0
Tomasz
Top achievements
Rank 1
answered on 08 Jan 2014, 07:26 AM
I'm sorry - I wanted to put this post for WinForms / gridview not ASP.NET AJAX / grid!
I do not know how it happened
Please administrator for the transfer.
0
Stefan
Telerik team
answered on 09 Jan 2014, 11:19 AM
Hello Tomasz,

Thank you for writing.

RadGridView uses UI virtualization for its cells, which means that the cells are being reused to display different data, hence it is necessary to reset each visual settings you apply. More information and examples you can find here: http://www.telerik.com/help/winforms/gridview-cells-formatting-cells.html.

I hope this helps. 

Regards,
Stefan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
Grid
Asked by
Tomasz
Top achievements
Rank 1
Answers by
Tomasz
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or