[RESOLVED] [2008] How to add animated alert to a datetime ?!
Hi everybody…:wave:
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…:)
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.
Re: [2008] How to add animated alert to a datetime ?!
Animated images cannot be used with ErrorProvider but may be you use animated icons.
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.
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...:wave:
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…:confused:
Regards...:)
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.
Re: [2008] How to add animated alert to a datetime ?!
Quote:
Originally Posted by HOTFIX
Hi jmcilhinney...:wave:
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…:confused:
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?
Re: [2008] How to add animated alert to a datetime ?!
65535 Attachment(s)
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)..:confused:
Please Help…:(
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:
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(DateTimePicker1)
ShowErrorIcon(DateTimePicker2)
ShowErrorIcon(DateTimePicker3)
End Sub
Private Sub ShowErrorIcon(ByVal dtPicker As DateTimePicker)
Dim errProvider As ErrorProvider
Try
errProvider = New ErrorProvider
errProvider.SetIconPadding(dtPicker, 5)
Select Case DateDiff(DateInterval.Day, Now, dtPicker.Value)
Case Is > 2
errProvider.Icon = My.Resources.OK
errProvider.SetError(dtPicker, "more than two days")
errProvider.BlinkStyle = ErrorBlinkStyle.NeverBlink
Case Is < 1
errProvider.Icon = My.Resources.Urgent
errProvider.SetError(dtPicker, "less than one day")
errProvider.BlinkStyle = ErrorBlinkStyle.AlwaysBlink
errProvider.BlinkRate = 100
Case Else
errProvider.Icon = My.Resources.Attention
errProvider.SetError(dtPicker, "between one and two days")
errProvider.BlinkStyle = ErrorBlinkStyle.AlwaysBlink
errProvider.BlinkRate = 800
End Select
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Re: [2008] How to add animated alert to a datetime ?!
Hi Deepak Sakpal...:wave:
The codes work perfectly as my requirements...:thumb:
Many Thanks :)
Best Regards...:wave: