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

Refresh issue in RadGridView

5 Answers 849 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 26 Aug 2010, 08:46 PM
Hello,

I have a problem with refreshing images in the cells of the rows while scrolling the grid.
When I try to scroll down the grid the new rows appear with artefacts (the images from upper rows appear in the bottom rows).
And when I try to play with scrolling these artefacts apper on different rows.

This issue will not happen if I have enough window size to display all the rows of the grid.

Is there any possibility to call some refresh() or redraw() or invalidate(), or some other method to get rid of these artefacts?
I tried many methods like refresh() but nothing happened.

Thanks

5 Answers, 1 is accepted

Sort by
0
Richard Slade
Top achievements
Rank 2
answered on 27 Aug 2010, 10:14 AM
Hi, 

Have you tried wrapping your update statements in 
Me.RadGridView.GridElement.BeginUpdate()
' Do some updating
Me.RadGridView.GridElement.EndUpdate()
?
Richard
0
Alex
Top achievements
Rank 1
answered on 27 Aug 2010, 11:31 AM
Hello Richard,

Thanks for your help )
No, I didn't try to solve the problem in this way, but I found another.

Actually, this issue happens in my custom cell:

// This cell will emulate the behaviour of checkbox cell + icon cell
//(all in one, something like the checkbox column with icon in standard ListView)

GridViewSpecialCellItem

 

: GridDataCellElement

 

 

 

 


where I replaced several methods:

protected

 

override Type ThemeEffectiveType

 

 

{

 

    get { return typeof(GridDataCellElement); }

}

 

 

protected override void CreateChildElements()

{

 

    base.CreateChildElements();

 

    checkBox =

new RadCheckBoxElement

 

 

    {

        Margin =

new Padding(0, 2, 0, 0),

 

        Text =

string.Empty,

 

        MinSize =

new Size(20, 20)

 

    };

    checkBox.ToggleStateChanged += CheckBoxStateChanged;

    Children.Add(checkBox);

    images =

new ImagePrimitive[IconsMax];

 

 

 

    for (int i = 0; i < IconsMax; i++)

    {

        images[i] =

new ImagePrimitive

 

 

        {

            Margin =

new Padding(0, 2, 0, 0),

 

            MinSize =

new Size(0, ImageSupport.IconSize.Height)

 

        };

        images[i].MouseDown += ImageMouseDown;

        Children.Add(images[i]);

    }

}

 

 

protected override SizeF ArrangeOverride(SizeF finalSize)

 

{

    Children[0].Arrange(

new RectangleF(5, 0, 20, 20));

 

    cbWidth = 30;

 

 


    for
(int i = 0; i < IconsMax; i++)

        Children[i + 1].Arrange(

new RectangleF(cbWidth + IconSize.Width + 5) * i, 0, IconSize.Width, IconSize.Height));

 

 

    RefreshImages();

 


    return
finalSize;

}

 

 

protected override void SetContentCore(object value)

{

    ...

 

 

 

    switch (CellValue.Checked)

    {

 

        case true:

        checkBox.ToggleState =

ToggleState.On;

 

 

        break;

 

 

        case false:

        checkBox.ToggleState =

ToggleState.Off;

 

 

        break;

 

    }

    ...
 

    RefreshImages();

 

}

 

 


 

private void RefreshImages()

{
    ... // redraw all images (icons)

 

}


So, I use void RefreshImages() in  void SetContentCore(object value) and in SizeF ArrangeOverride(SizeF finalSize).
The last one is called when I scroll RadGridView (and this is the way to redraw images one more time).

May be this is not the best way, but it works for me.

Also I can say that there is real problem of artefacts while scrolling RadGridView. And I only found the way how to trick it.





0
Svett
Telerik team
answered on 01 Sep 2010, 08:25 AM
Hello Alex,

I did not manage to reproduce the issue following the supplied code snippet. Can you send a sample project where the issue is can be reproduced? Please note that you should create a new support ticket in order to attach your files.

I am looking forward to your response.

Sincerely yours,
Svett
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
Alex
Top achievements
Rank 1
answered on 29 Oct 2010, 10:03 AM

Sorry for late response. After many unsuccessful tries of using custom cell I decided to use the separate column for images.
It solved the problem with images.

But when I began to change font size and color for some rows the new problem with refreshing text in cells began.
I spent many time to fix this issue and found the way with CellFormatting event:

Something like this (I use  padding < 0 to shift the text for some cells):

private void RadGridView_CellFormatting(object sender, CellFormattingEventArgs e)

{
    ...
    if
(e.CellElement.ColumnIndex == 3)

        e.CellElement.Padding = new Padding(-paddingleft, 0, -paddingRight, 0);

    else

        e.CellElement.ResetValue(VisualElement.PaddingProperty, ValueResetFlags.Local); 
    ...

}

So as I understood, the main idea is if you change some property in this event for particular cell, then you should
ALSWAYS reset this property for other cells.

IMHO it is redundant.

Also I read about your mechanism of virtualization of rows in grid. It is cool until you will want to refresh some row\cell
to get rid of artefacts while scrolling the grid. And as I see there is no way to redraw some cell outside
RadGridView_CellFormatting() event, because there is no direct relationship between data and layout of the cell.
I didn't find such methods. Are they exist?

0
Svett
Telerik team
answered on 03 Nov 2010, 03:52 PM
Hello Alex,

You can force processing the CellFormatting event by invoking the InvalidateRow method of the GridViewRowInfo instance:

this.radGridView1.Rows[0].InvalidateRow();

I hope this helps.

Sincerely yours,
Svett
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
Alex
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Alex
Top achievements
Rank 1
Svett
Telerik team
Share this question
or