Results 1 to 11 of 11

Thread: [RESOLVED] [2008] How to add animated alert to a datetime ?!

  1. #1

    Thread Starter
    Lively Member HOTFIX's Avatar
    Join Date
    Sep 2008
    Posts
    91

    Resolved [RESOLVED] [2008] How to add animated alert to a datetime ?!

    Hi everybody…

    I’m newbie in vb.net…

    I’ve created a vb.net form which contain two datetimepicker by the following format “ddd dd MMM yyyy HH:mm” , a button and three PictureBoxs.

    Form Descriptions:
    DateTimePicker1: stored datetime value using application setting
    DateTimePicker2: current datetime value
    Button1: send the value of current datetime to stored datetime
    Green image (OK)
    Yellow image (Attention)
    Red image (Urgent)

    I want to add animated alert related to the values in datetimepickers current and stored datetime by the following situations:-

    Situation 1- When the current datetime value of datetimepicker is difference of two days and above of stored datetime value:
    Green image (OK) steady visible=true
    Yellow image (Attention) visible=false
    Red image (Urgent) visible=false
    *For example if the current datetime is “Tue 07 Oct 2008 17:15” and the stored datetime is “Fri 10 Oct 2008 17:15” the green image will be visible & steady , other images are hidden until the next situation.

    Situation 2- When the current datetime value of datetimepicker reach two day before stored date at time 06:30
    Green image (OK) visible=false
    Yellow image (Attention) blinks visible=true
    Red image (Urgent) visible=false
    *For example if the current datetime is “Mon 07 Oct 2008 06:30” and the stored datetime is “Fri 10 Oct 2008 17:15” the Yellow image will be visible & blinks, other images are hidden until the next situation.

    Situation 3- When the current datetime value of datetimepicker is equal of stored datetime value at time 06:30
    Green image (OK) visible=false
    Yellow image (Attention) visible=false
    Red image (Urgent) blinks visible=true
    *For example if the current datetime is “Fri 10 Oct 2008 06:30” and the stored datetime is “Fri 10 Oct 2008 17:15” the Red image will be visible & blinks, other images are hidden until the next situation.

    Please any suggestions and ideas
    Regards…
    Last edited by HOTFIX; Oct 12th, 2008 at 01:09 PM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2008] How to add animated alert to a datetime ?!

    You should look at the ErrorProvider class. You can add one to your form and then associate it with one or more controls. It can display an Icon of your choosing, which you can set at design time or in code, and it can be set to blink or not. You can just handle the ValueChanged event of your DateTimePicker and then set the ErrorProvider properties accordingly.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2008] How to add animated alert to a datetime ?!

    Quote Originally Posted by Deepak Sakpal
    Animated images cannot be used with ErrorProvider but may be you use animated icons.
    From the first post it looks like the only "animation" that's required is blinking, which the ErrorProvider specifically does support.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Lively Member HOTFIX's Avatar
    Join Date
    Sep 2008
    Posts
    91

    Re: [2008] How to add animated alert to a datetime ?!

    Quote Originally Posted by jmcilhinney
    You should look at the ErrorProvider class. You can add one to your form and then associate it with one or more controls. It can display an Icon of your choosing, which you can set at design time or in code, and it can be set to blink or not. You can just handle the ValueChanged event of your DateTimePicker and then set the ErrorProvider properties accordingly.
    Hi jmcilhinney...

    Can please provide me the vb.net codes calculation of three situations alert using the ErrorProvider class because my programming knowledge level in vb.net is very low…

    Regards...

  6. #6
    Frenzied Member MaximilianMayrhofer's Avatar
    Join Date
    Aug 2007
    Location
    IM IN YR LOOP
    Posts
    2,001

    Re: [2008] How to add animated alert to a datetime ?!

    Just change the icon and blinkstyle of the error provider for each of the three possible situations.

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2008] How to add animated alert to a datetime ?!

    Quote Originally Posted by HOTFIX
    Hi jmcilhinney...

    Can please provide me the vb.net codes calculation of three situations alert using the ErrorProvider class because my programming knowledge level in vb.net is very low…

    Regards...
    Here's your chance to improve it. Have you read the documentation for the ErrorProvider class? Have you created a test project and experimented with it to see what effect each member has? THAT is how you learn. How do you suppose I know how to use an ErrorProvider?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8

    Thread Starter
    Lively Member HOTFIX's Avatar
    Join Date
    Sep 2008
    Posts
    91

    Re: [2008] How to add animated alert to a datetime ?!

    UP

  9. #9

    Thread Starter
    Lively Member HOTFIX's Avatar
    Join Date
    Sep 2008
    Posts
    91

    Re: [2008] How to add animated alert to a datetime ?!

    Hi…
    I found the codes for datetime alert…

    Code:
    Public Class Form1
        Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
            My.Settings.Save()
        End Sub
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Me.DateTimePicker1.DataBindings.Add(New System.Windows.Forms.Binding("Value", _
                                                Global.DateTimeAlert.My.MySettings.Default, "Date1", _
                                                True, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged))
            ShowErrorIcon()
        End Sub
    
        Private Sub ShowErrorIcon()
            Try
                Me.ErrorProvider1.SetIconPadding(Me.DateTimePicker1, 5)
                Select Case DateDiff(DateInterval.Day, Now, Me.DateTimePicker1.Value)
                    Case Is > 2
                        Me.ErrorProvider1.Icon = My.Resources.OK
                        Me.ErrorProvider1.SetError(Me.DateTimePicker1, "more than two days")
                        Me.ErrorProvider1.BlinkStyle = ErrorBlinkStyle.NeverBlink
                    Case Is < 1
                        Me.ErrorProvider1.Icon = My.Resources.Urgent
                        Me.ErrorProvider1.SetError(Me.DateTimePicker1, "less than one day")
                        Me.ErrorProvider1.BlinkStyle = ErrorBlinkStyle.AlwaysBlink
                        Me.ErrorProvider1.BlinkRate = 100
                    Case Else
                        Me.ErrorProvider1.Icon = My.Resources.Attention
                        Me.ErrorProvider1.SetError(Me.DateTimePicker1, "between one and two days")
                        Me.ErrorProvider1.BlinkStyle = ErrorBlinkStyle.AlwaysBlink
                        Me.ErrorProvider1.BlinkRate = 800
                End Select
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End Sub
    
        Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            ShowErrorIcon()
        End Sub
    End Class
    Unfortunately I couldn’t figure out how to make it work with more than one dateTimePickers (multi DateTimePickers)..

    Please Help…
    Last edited by HOTFIX; Oct 13th, 2008 at 05:01 AM.

  10. #10
    PowerPoster Deepak Sakpal's Avatar
    Join Date
    Mar 2002
    Location
    Mumbai, India
    Posts
    2,424

    Re: [2008] How to add animated alert to a datetime ?!

    Delete the ErrorProvider1 control that you have added in design mode and use the code below. It creates the new instance of error provider control for each date time picker control at run-time. I have modified your code a little bit. See if that suits your requirements.

    vb.net Code:
    1. Private Sub Form1_Load( _
    2.   ByVal sender As System.Object, _
    3.   ByVal e As System.EventArgs _
    4. ) Handles MyBase.Load
    5.  
    6.   Me.DateTimePicker1.DataBindings.Add(New System.Windows.Forms.Binding("Value", _
    7.                                       Global.DateTimeAlert.My.MySettings.Default, "Date1", _
    8.                                       True, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged))
    9.   ShowErrorIcon(DateTimePicker1)
    10.   ShowErrorIcon(DateTimePicker2)
    11.   ShowErrorIcon(DateTimePicker3)
    12. End Sub
    13.  
    14. Private Sub ShowErrorIcon(ByVal dtPicker As DateTimePicker)
    15.   Dim errProvider As ErrorProvider
    16.  
    17.   Try
    18.     errProvider = New ErrorProvider
    19.     errProvider.SetIconPadding(dtPicker, 5)
    20.  
    21.     Select Case DateDiff(DateInterval.Day, Now, dtPicker.Value)
    22.       Case Is > 2
    23.         errProvider.Icon = My.Resources.OK
    24.         errProvider.SetError(dtPicker, "more than two days")
    25.         errProvider.BlinkStyle = ErrorBlinkStyle.NeverBlink
    26.       Case Is < 1
    27.         errProvider.Icon = My.Resources.Urgent
    28.         errProvider.SetError(dtPicker, "less than one day")
    29.         errProvider.BlinkStyle = ErrorBlinkStyle.AlwaysBlink
    30.         errProvider.BlinkRate = 100
    31.       Case Else
    32.         errProvider.Icon = My.Resources.Attention
    33.         errProvider.SetError(dtPicker, "between one and two days")
    34.         errProvider.BlinkStyle = ErrorBlinkStyle.AlwaysBlink
    35.         errProvider.BlinkRate = 800
    36.     End Select
    37.  
    38.   Catch ex As Exception
    39.     MessageBox.Show(ex.Message)
    40.   End Try
    41. End Sub

  11. #11

    Thread Starter
    Lively Member HOTFIX's Avatar
    Join Date
    Sep 2008
    Posts
    91

    Re: [2008] How to add animated alert to a datetime ?!

    Hi Deepak Sakpal...

    The codes work perfectly as my requirements...

    Many Thanks

    Best Regards...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width