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

radgridview flashing border

18 Answers 158 Views
GridView
This is a migrated thread and some comments may be shown as answers.
tphan
Top achievements
Rank 1
tphan asked on 02 May 2012, 12:04 PM
void RadGridView_RowFormatting(object sender, RowFormattingEventArgs e)
        {
            object value = e.RowElement.RowInfo.Cells[1].Value;
 
            if (value != null)
            {
                if (e.RowElement.Tag == null)
                {
                    e.RowElement.DrawBorder = true;
                    e.RowElement.GradientStyle = GradientStyles.Solid;
                     
                    CustomAnimatedPropertySetting setting = new CustomAnimatedPropertySetting(e.RowElement);
 
                    setting.ApplyValue(e.RowElement);
 
                    e.RowElement.Tag = setting;
                }
            }
            else
            {
                CustomAnimatedPropertySetting setting = e.RowElement.Tag as CustomAnimatedPropertySetting;
 
                if (setting != null)
                {
                    e.RowElement.Tag = null;
 
                    setting.Stop();
 
                    e.RowElement.ResetValue(LightVisualElement.DrawBorderProperty, ValueResetFlags.Local);
                    e.RowElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local);
                    e.RowElement.ResetValue(LightVisualElement.BorderColorProperty, ValueResetFlags.Animation | ValueResetFlags.Local);
                }
            }
 
        }
 
        public class CustomAnimatedPropertySetting : AnimatedPropertySetting
        {
            GridRowElement row;
             
            public CustomAnimatedPropertySetting(GridRowElement row)
                : base(
                        LightVisualElement.BorderColorProperty,
                        Color.Blue, // start value    
                        Color.White, // end value    
                        40, // number of animation frames    
                        10 // time in ms between 2 frames
                )
            {
                this.row = row;
                this.AnimationFinished += new AnimationFinishedEventHandler(CustomAnimatedPropertySetting_AnimationFinished);
                this.AnimatorStyle = AnimatorStyles.AnimateAlways;
                this.ApplyEasingType = RadEasingType.Linear;
                this.UnapplyEasingType = RadEasingType.Linear;
            }
 
             
            public void Stop()
            {
                GridRowElement o = this.row;
                this.row = null;
                this.Stop(o);
            }
 
            void CustomAnimatedPropertySetting_AnimationFinished(object sender, AnimationStatusEventArgs e)
            {
                if (row != null && row.Parent != null)
                {
                    this.ApplyValue(row);
                }
                else
                {
                    row = null;
                    this.AnimationFinished -= new AnimationFinishedEventHandler(CustomAnimatedPropertySetting_AnimationFinished);
                }
            }
 
        }

Hi Folks,


I would like to make the border become flashing... but it failed to do so....what's wrong with the code ?

Thanks!
Charles.

18 Answers, 1 is accepted

Sort by
0
Richard Slade
Top achievements
Rank 2
answered on 02 May 2012, 01:58 PM
Hi Charles, 

I'm not sure if this is exactly what you want to achieve, but try this to replace part of your code in the row formatting event

if (value != null)
{
    if (e.RowElement.Tag == null)
    {
        e.RowElement.BorderWidth = 2;
        e.RowElement.DrawBorder = true;
        e.RowElement.BorderGradientStyle = GradientStyles.Solid;
 
        CustomAnimatedPropertySetting setting = new CustomAnimatedPropertySetting(e.RowElement);
        setting.ApplyValue(e.RowElement);
 
        e.RowElement.Tag = setting;
    }
}

hope that helps
Richard
0
tphan
Top achievements
Rank 1
answered on 02 May 2012, 03:13 PM
Hi Richard,

I wanted to do something look like Excel...when you copy a value from excel's cell... a flashing border will appear...

I am not sure how to use   e.RowElement.BorderDashStyle

Many Thanks!
Charles.
0
Richard Slade
Top achievements
Rank 2
answered on 02 May 2012, 03:36 PM
Charles, 

The dash style just applies the type of border (dash, dot etc..). 
However, it looks like you need to apply your formatting to the cell, not the row. This would be done in the CellFormatting Event rather than the RowFormatting event. 

Hope this helps
Richard
0
tphan
Top achievements
Rank 1
answered on 02 May 2012, 03:44 PM
Hi Richard,

Yes ! Actually I would like to make the whole row flashing...not only a cell is flashing...But I can't made it work at all...How to achieve the dot flashing for a row ?

Thanks!
Charles.
0
Richard Slade
Top achievements
Rank 2
answered on 02 May 2012, 04:06 PM
Hi Charles, 

Here's a sample for when you click on a Row. 

void radGridView1_RowFormatting(object sender, RowFormattingEventArgs e)
{
    if (e.RowElement.IsSelected)
    {
        e.RowElement.BorderWidth = 3;
        e.RowElement.DrawBorder = true;
        e.RowElement.BorderGradientStyle = GradientStyles.Solid;
        e.RowElement.BorderDashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
 
        CustomAnimatedPropertySetting setting = new CustomAnimatedPropertySetting(e.RowElement);
        setting.ApplyValue(e.RowElement);

    }
    else
    {
        e.RowElement.ResetValue(LightVisualElement.DrawBorderProperty, ValueResetFlags.Local);
        e.RowElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local);
        e.RowElement.ResetValue(LightVisualElement.BorderColorProperty, ValueResetFlags.Animation | ValueResetFlags.Local);
    }
}

Hope that helps
Richard
0
tphan
Top achievements
Rank 1
answered on 02 May 2012, 04:18 PM
Hi Richard,

it looks pretty good ! Million Thanks !

Attached the result ;-)

Lastly, Just ask your advice...Instead of 4 rows flashing by its own.... combine them flashing together to make as 1 big row (consists of 4 rows) flasing ? If it is become more complex... I rather to leave it and use the current approach.

Charles.


0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 02 May 2012, 04:41 PM
Hi Charles, 

This is probably possible, however, there would be complications. If there were 2 or more rows selected, then you would need to turn off the top or bottom borders to create the look of a single border covering all rows. On top of this, if rows were not all selected at the same time, then the flash rate would appear at different times giving a disjointed look when it is meant to look like one selected selection. 

I hope this explains
Richard
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 02 May 2012, 04:41 PM
Please remember to mark helpful posts as answer, and if you need further help, just let me know
Richard
0
Emilio
Top achievements
Rank 1
answered on 08 May 2012, 09:16 AM
Hi,

Can I request for a vb.net equivalent of code.

Thanks,
0
Richard Slade
Top achievements
Rank 2
answered on 08 May 2012, 10:18 AM
Hello, 

In VB, it would look like this. (note that the Handles clause needs adding to the method)

Private Sub radGridView1_RowFormatting(sender As Object, e As RowFormattingEventArgs)
    If e.RowElement.IsSelected Then
        e.RowElement.BorderWidth = 3
        e.RowElement.DrawBorder = True
        e.RowElement.BorderGradientStyle = GradientStyles.Solid
        e.RowElement.BorderDashStyle = System.Drawing.Drawing2D.DashStyle.Dot
 
        Dim setting As New CustomAnimatedPropertySetting(e.RowElement)
 
        setting.ApplyValue(e.RowElement)
    Else
        e.RowElement.ResetValue(LightVisualElement.DrawBorderProperty, ValueResetFlags.Local)
        e.RowElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local)
        e.RowElement.ResetValue(LightVisualElement.BorderColorProperty, ValueResetFlags.Animation Or ValueResetFlags.Local)
    End If
End Sub

Telerik provide an excellent code converter, to convert to and from C#/VB. You can find that here
hope that helps
Richard
0
tphan
Top achievements
Rank 1
answered on 08 May 2012, 10:39 AM
Hi Richard,

Sorry to let you that when I exist the form... I got the stack overflow error... the error occurs in the line

this.ApplyValue(row); <-- error hit on this line !

Thanks.
Charles

0
Emilio
Top achievements
Rank 1
answered on 08 May 2012, 01:22 PM
Hi,

Thanks, we would like to use the flashing when in cells that fails validation.

alexis
0
Richard Slade
Top achievements
Rank 2
answered on 08 May 2012, 01:22 PM
Hi Charles, 

I haven't been able to replicate this. Can you post a full sample please, using the format code block that shows this happening and I'll be happy to take a look at it for you
Thanks
Richard
0
Jack
Telerik team
answered on 11 May 2012, 07:28 AM
Hello Charles,

We are still not able to reproduce this issue. Please, could you prepare a sample application and send it to us. We will try to locate the issue and to find a proper solution. 

I am looking forward to your project.
 
All the best,
Jack
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
0
tphan
Top achievements
Rank 1
answered on 11 May 2012, 07:37 AM
Agree...Thanks for your team effort always... somehow I need to spend time to separate my code in this weekend and create a lightweight version and give it to you...If it only contains source code without database. is still okay for you ?
0
Jack
Telerik team
answered on 15 May 2012, 12:16 PM
Hi Charles,

Thank you for this update. Yes, it is OK to send us only the code, if we can test with dummy data. Thank you in advance.

Looking forward to your reply.
 
Greetings,
Jack
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
0
tphan
Top achievements
Rank 1
answered on 28 May 2012, 09:58 AM
Hi Jack,

I changed my approach... actually, I would like to click a button and hightlight some rows...e.g. let's say row 7 and row 9 within a grid.  

How can I acheive it instead of control the flashing by RowFormatting ?

Thanks.
Charles.


0
Nikolay
Telerik team
answered on 30 May 2012, 04:54 PM
Hello Charles,

For this task you again need the RowFormatting event. In order to change the colors on demand you need to call the Update method of the TableElement passing the GridUINotifyAction.StateChanged value. This will fire the RowFormatting event and with a boolean flag set in the button_Click event handler and consumed by the RowFormatting event you can make your rows take your color. A similar on-demand scenario is demonstrated for cells in the Formatting cells on demand section in this article.

I hope this helps.

Regards,
Nikolay
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
tphan
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
tphan
Top achievements
Rank 1
Emilio
Top achievements
Rank 1
Jack
Telerik team
Nikolay
Telerik team
Share this question
or