radgridview flashing border

19 posts, 2 answers
  1. tphan
    tphan avatar
    22 posts
    Member since:
    Jun 2012

    Posted 02 May 2012 Link to this post

    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.

  2. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 02 May 2012 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. tphan
    tphan avatar
    22 posts
    Member since:
    Jun 2012

    Posted 02 May 2012 Link to this post

    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.
  5. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 02 May 2012 Link to this post

    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
  6. tphan
    tphan avatar
    22 posts
    Member since:
    Jun 2012

    Posted 02 May 2012 Link to this post

    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.
  7. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 02 May 2012 Link to this post

    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
  8. tphan
    tphan avatar
    22 posts
    Member since:
    Jun 2012

    Posted 02 May 2012 Link to this post

    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.


  9. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 02 May 2012 Link to this post

    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
  10. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 02 May 2012 Link to this post

    Please remember to mark helpful posts as answer, and if you need further help, just let me know
    Richard
  11. Emilio
    Emilio avatar
    15 posts
    Member since:
    Mar 2012

    Posted 08 May 2012 Link to this post

    Hi,

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

    Thanks,
  12. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 08 May 2012 Link to this post

    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
  13. tphan
    tphan avatar
    22 posts
    Member since:
    Jun 2012

    Posted 08 May 2012 Link to this post

    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

  14. Emilio
    Emilio avatar
    15 posts
    Member since:
    Mar 2012

    Posted 08 May 2012 Link to this post

    Hi,

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

    alexis
  15. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 08 May 2012 Link to this post

    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
  16. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 11 May 2012 Link to this post

    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 >>
  17. tphan
    tphan avatar
    22 posts
    Member since:
    Jun 2012

    Posted 11 May 2012 Link to this post

    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 ?
  18. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 15 May 2012 Link to this post

    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 >>
  19. tphan
    tphan avatar
    22 posts
    Member since:
    Jun 2012

    Posted 28 May 2012 Link to this post

    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.


  20. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 30 May 2012 Link to this post

    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 >>
Back to Top
UI for WinForms is Visual Studio 2017 Ready