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

CellElement with Telerik RadControls for WinForms Q2 2010 SP1 (v2010.2.10.0806)

3 Answers 160 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jesús
Top achievements
Rank 1
Jesús asked on 14 Sep 2010, 08:26 PM

Hi, I have been developing a simple application with Telerik in a previous version (i don't know exactly wich it was) But now our company acquired the version 2010 SP1 (v2010.2.10.0806 and I'm experiencing a lot of my problems. The most important is that now i cant access to a cell from a RadGridViewCell by the CellElement propertie. In my code i wrote:

private void gridviewname_CurrentCellChanged(object sender, CurrentCellChangedEventArgs e) {

if (e.NewCell != null) {

gridviewname.Rows[e.NewCell.RowInfo.Index].Cells[2].CellElement.Enabled = false;

}

}
 

But the problem is that with the new version i can't disable a cell from a gridview by that way. I need disable the cell in the CurrentCellChanged event, NOT another. I know it's possible to disable a cell in the CellFormatting event by writing "e.CellElement.Enabled = false" but i really need to disable it in CurrentCellChanged event. What can I do? Thank you!

(sorry, i don't speak english well as you already notice xD)

3 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 17 Sep 2010, 06:01 PM
Hello Jesús,

RadGridView supports UI virtualization. Visual elements are created only for the elements that are currently visible. When scrolling or applying data operations the cells are reused. This feature enables RadGridView to handle large number of columns and rows (e.g. 1000x1000) without performance loss. You can find more about this feature in the following blog article.

Because of all this it is not safe to access the CellElement property and that is why we removed it. The correct way to do this is by handling the CellFormatting event. Please, could you describe your scenario and I will try to find the best option. 

I am looking forward to your reply.

Greetings,
Jack
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jesús
Top achievements
Rank 1
answered on 17 Sep 2010, 06:20 PM

Hi, Thanks for your answer. My problem is that everytime the user clicks in a grid view cell obviously it fires the CurrentCellChanged event. So, i query the value in the database and, according the result, the cell could be enabled or disabled. Even, i have a OK button in other place into the form, so if the user select a value, for example "New and old products", the grid turns into different colors, green for the cells with new products and blue for those with old products and maybe red for the rest. I handled that firing a Clickbutton event an coding "gridviewname.Rows[e.NewCell.RowInfo.Index].Cells[2].CellElement.Enabled = false;" or  "gridviewname.Rows[selectedRow].VisualElement.BackColor = Color.White" But now those properties doesn't exist and i don't know how i can do the same handling the CellFormatting event. could you help me please'? :)

0
Jack
Telerik team
answered on 21 Sep 2010, 04:56 PM
Hello Jesús,

You can handle this in the CellFormatting event. You can cause this event to fire by calling the InvalidateCell or InvalidateRow event. Please consider this code:

int rowId = -1;
this.radGridView1.Rows[3].InvalidateRow();
 
void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
{
    if (rowId > 0 && e.CellElement.RowIndex == rowId)
    {
        if (e.CellElement.ColumnInfo.Name == "Value")
        {
            e.CellElement.Enabled = false;
            return;
        }
    }
    e.CellElement.Enabled = true;
}

I hope it helps.

Best wishes,
Jack
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Jesús
Top achievements
Rank 1
Answers by
Jack
Telerik team
Jesús
Top achievements
Rank 1
Share this question
or