|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
button flash with red and white colorHi, All,
how to flash button with 2 color( eg. red and white)? then when user click button, the button stop flash and stay red color? Thanks "martin1" <mart***@discussions.microsoft.com> schrieb: You may want to use a timer component ('System.Windows.Forms.Timer') and use > how to flash button with 2 color( eg. red and white)? then when user click > button, the button stop flash and stay red color? the timer to set the button control's 'BackColor' property to the desired color. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> I tried and it doesn't work, any sample code? Thanks
Show quoteHide quote "Herfried K. Wagner [MVP]" wrote: > "martin1" <mart***@discussions.microsoft.com> schrieb: > > how to flash button with 2 color( eg. red and white)? then when user click > > button, the button stop flash and stay red color? > > You may want to use a timer component ('System.Windows.Forms.Timer') and use > the timer to set the button control's 'BackColor' property to the desired > color. > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://classicvb.org/petition/> > > Private ButtonColor As System.Drawing.Color
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick If ButtonColor = Color.Red Then ButtonColor = Color.White Else ButtonColor = Color.Red End If Me.Button1.BackColor = ButtonColor End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ButtonColor = Color.Red Me.Button1.BackColor = ButtonColor Me.Timer1.Interval = 1000 ' 1 sec Me.Timer1.Start() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.Timer1.Stop() ButtonColor = Color.Red Me.Button1.BackColor = ButtonColor End Sub I tried it in VS 2005. Ahmed martin1 wrote: Show quoteHide quote > I tried and it doesn't work, any sample code? Thanks > > "Herfried K. Wagner [MVP]" wrote: > > > "martin1" <mart***@discussions.microsoft.com> schrieb: > > > how to flash button with 2 color( eg. red and white)? then when user click > > > button, the button stop flash and stay red color? > > > > You may want to use a timer component ('System.Windows.Forms.Timer') and use > > the timer to set the button control's 'BackColor' property to the desired > > color. > > > > -- > > M S Herfried K. Wagner > > M V P <URL:http://dotnet.mvps.org/> > > V B <URL:http://classicvb.org/petition/> > > > > Thank you. Ahmed,
The code i wrote works also: Dim aTimer As New System.Timers.Timer() AddHandler aTimer.Elapsed, AddressOf OnTimedEvent 'Set the Interval to 1 seconds. aTimer.Interval = 1000 aTimer.Enabled = True ButtonI.BackColor = Color.Red Else ButtonI.BackColor = Color.White End If End Sub Private Sub OnTimedEvent(ByVal source As Object, ByVal e As ElapsedEventArgs) 'test button flash If (ButtonI.BackColor = Color.Red) Then ButtonI.BackColor = Color.White ElseIf (ButtonI.BackColor = Color.White) Then ButtonI.BackColor = Color.Red End If End Sub Show quoteHide quote "Ahmed" wrote: > Private ButtonColor As System.Drawing.Color > Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles Timer1.Tick > If ButtonColor = Color.Red Then > ButtonColor = Color.White > > Else > ButtonColor = Color.Red > End If > Me.Button1.BackColor = ButtonColor > End Sub > > Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles MyBase.Load > > ButtonColor = Color.Red > Me.Button1.BackColor = ButtonColor > Me.Timer1.Interval = 1000 ' 1 sec > Me.Timer1.Start() > End Sub > > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles Button1.Click > Me.Timer1.Stop() > ButtonColor = Color.Red > Me.Button1.BackColor = ButtonColor > End Sub > > I tried it in VS 2005. > > Ahmed > martin1 wrote: > > I tried and it doesn't work, any sample code? Thanks > > > > "Herfried K. Wagner [MVP]" wrote: > > > > > "martin1" <mart***@discussions.microsoft.com> schrieb: > > > > how to flash button with 2 color( eg. red and white)? then when user click > > > > button, the button stop flash and stay red color? > > > > > > You may want to use a timer component ('System.Windows.Forms.Timer') and use > > > the timer to set the button control's 'BackColor' property to the desired > > > color. > > > > > > -- > > > M S Herfried K. Wagner > > > M V P <URL:http://dotnet.mvps.org/> > > > V B <URL:http://classicvb.org/petition/> > > > > > > > > You're welcome :D
martin1 wrote: Show quoteHide quote > Thank you. Ahmed, > > The code i wrote works also: > > Dim aTimer As New System.Timers.Timer() > AddHandler aTimer.Elapsed, AddressOf OnTimedEvent > 'Set the Interval to 1 seconds. > aTimer.Interval = 1000 > aTimer.Enabled = True > ButtonI.BackColor = Color.Red > Else > ButtonI.BackColor = Color.White > End If > End Sub > Private Sub OnTimedEvent(ByVal source As Object, ByVal e As > ElapsedEventArgs) > 'test button flash > If (ButtonI.BackColor = Color.Red) Then > ButtonI.BackColor = Color.White > ElseIf (ButtonI.BackColor = Color.White) Then > ButtonI.BackColor = Color.Red > End If > End Sub > > "Ahmed" wrote: > > > Private ButtonColor As System.Drawing.Color > > Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As > > System.EventArgs) Handles Timer1.Tick > > If ButtonColor = Color.Red Then > > ButtonColor = Color.White > > > > Else > > ButtonColor = Color.Red > > End If > > Me.Button1.BackColor = ButtonColor > > End Sub > > > > Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As > > System.EventArgs) Handles MyBase.Load > > > > ButtonColor = Color.Red > > Me.Button1.BackColor = ButtonColor > > Me.Timer1.Interval = 1000 ' 1 sec > > Me.Timer1.Start() > > End Sub > > > > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As > > System.EventArgs) Handles Button1.Click > > Me.Timer1.Stop() > > ButtonColor = Color.Red > > Me.Button1.BackColor = ButtonColor > > End Sub > > > > I tried it in VS 2005. > > > > Ahmed > > martin1 wrote: > > > I tried and it doesn't work, any sample code? Thanks > > > > > > "Herfried K. Wagner [MVP]" wrote: > > > > > > > "martin1" <mart***@discussions.microsoft.com> schrieb: > > > > > how to flash button with 2 color( eg. red and white)? then when user click > > > > > button, the button stop flash and stay red color? > > > > > > > > You may want to use a timer component ('System.Windows.Forms.Timer') and use > > > > the timer to set the button control's 'BackColor' property to the desired > > > > color. > > > > > > > > -- > > > > M S Herfried K. Wagner > > > > M V P <URL:http://dotnet.mvps.org/> > > > > V B <URL:http://classicvb.org/petition/> > > > > > > > > > > > > Hi, Ahmed,
when run yuor code, get error messgae "Handles clause requires a WithEvents variable defined in the containing type or one of its base types " from Timer1 below. Any clue? Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Show quoteHide quote "Ahmed" wrote: > Private ButtonColor As System.Drawing.Color > Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles Timer1.Tick > If ButtonColor = Color.Red Then > ButtonColor = Color.White > > Else > ButtonColor = Color.Red > End If > Me.Button1.BackColor = ButtonColor > End Sub > > Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles MyBase.Load > > ButtonColor = Color.Red > Me.Button1.BackColor = ButtonColor > Me.Timer1.Interval = 1000 ' 1 sec > Me.Timer1.Start() > End Sub > > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles Button1.Click > Me.Timer1.Stop() > ButtonColor = Color.Red > Me.Button1.BackColor = ButtonColor > End Sub > > I tried it in VS 2005. > > Ahmed > martin1 wrote: > > I tried and it doesn't work, any sample code? Thanks > > > > "Herfried K. Wagner [MVP]" wrote: > > > > > "martin1" <mart***@discussions.microsoft.com> schrieb: > > > > how to flash button with 2 color( eg. red and white)? then when user click > > > > button, the button stop flash and stay red color? > > > > > > You may want to use a timer component ('System.Windows.Forms.Timer') and use > > > the timer to set the button control's 'BackColor' property to the desired > > > color. > > > > > > -- > > > M S Herfried K. Wagner > > > M V P <URL:http://dotnet.mvps.org/> > > > V B <URL:http://classicvb.org/petition/> > > > > > > > > You need to add a timer component to the form.
martin1 wrote: Show quoteHide quote > Hi, Ahmed, > > when run yuor code, get error messgae "Handles clause requires a WithEvents > variable defined in the containing type or one of its base types " from > Timer1 below. Any clue? > > Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles Timer1.Tick > > "Ahmed" wrote: > > > Private ButtonColor As System.Drawing.Color > > Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As > > System.EventArgs) Handles Timer1.Tick > > If ButtonColor = Color.Red Then > > ButtonColor = Color.White > > > > Else > > ButtonColor = Color.Red > > End If > > Me.Button1.BackColor = ButtonColor > > End Sub > > > > Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As > > System.EventArgs) Handles MyBase.Load > > > > ButtonColor = Color.Red > > Me.Button1.BackColor = ButtonColor > > Me.Timer1.Interval = 1000 ' 1 sec > > Me.Timer1.Start() > > End Sub > > > > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As > > System.EventArgs) Handles Button1.Click > > Me.Timer1.Stop() > > ButtonColor = Color.Red > > Me.Button1.BackColor = ButtonColor > > End Sub > > > > I tried it in VS 2005. > > > > Ahmed > > martin1 wrote: > > > I tried and it doesn't work, any sample code? Thanks > > > > > > "Herfried K. Wagner [MVP]" wrote: > > > > > > > "martin1" <mart***@discussions.microsoft.com> schrieb: > > > > > how to flash button with 2 color( eg. red and white)? then when user click > > > > > button, the button stop flash and stay red color? > > > > > > > > You may want to use a timer component ('System.Windows.Forms.Timer') and use > > > > the timer to set the button control's 'BackColor' property to the desired > > > > color. > > > > > > > > -- > > > > M S Herfried K. Wagner > > > > M V P <URL:http://dotnet.mvps.org/> > > > > V B <URL:http://classicvb.org/petition/> > > > > > > > > > > > > is this import correct to add Timer component?
Imports System.Timers Show quoteHide quote "Ahmed" wrote: > You need to add a timer component to the form. > > martin1 wrote: > > Hi, Ahmed, > > > > when run yuor code, get error messgae "Handles clause requires a WithEvents > > variable defined in the containing type or one of its base types " from > > Timer1 below. Any clue? > > > > Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As > > System.EventArgs) Handles Timer1.Tick > > > > "Ahmed" wrote: > > > > > Private ButtonColor As System.Drawing.Color > > > Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As > > > System.EventArgs) Handles Timer1.Tick > > > If ButtonColor = Color.Red Then > > > ButtonColor = Color.White > > > > > > Else > > > ButtonColor = Color.Red > > > End If > > > Me.Button1.BackColor = ButtonColor > > > End Sub > > > > > > Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As > > > System.EventArgs) Handles MyBase.Load > > > > > > ButtonColor = Color.Red > > > Me.Button1.BackColor = ButtonColor > > > Me.Timer1.Interval = 1000 ' 1 sec > > > Me.Timer1.Start() > > > End Sub > > > > > > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As > > > System.EventArgs) Handles Button1.Click > > > Me.Timer1.Stop() > > > ButtonColor = Color.Red > > > Me.Button1.BackColor = ButtonColor > > > End Sub > > > > > > I tried it in VS 2005. > > > > > > Ahmed > > > martin1 wrote: > > > > I tried and it doesn't work, any sample code? Thanks > > > > > > > > "Herfried K. Wagner [MVP]" wrote: > > > > > > > > > "martin1" <mart***@discussions.microsoft.com> schrieb: > > > > > > how to flash button with 2 color( eg. red and white)? then when user click > > > > > > button, the button stop flash and stay red color? > > > > > > > > > > You may want to use a timer component ('System.Windows.Forms.Timer') and use > > > > > the timer to set the button control's 'BackColor' property to the desired > > > > > color. > > > > > > > > > > -- > > > > > M S Herfried K. Wagner > > > > > M V P <URL:http://dotnet.mvps.org/> > > > > > V B <URL:http://classicvb.org/petition/> > > > > > > > > > > > > > > > > > > If you are using visual studio, you open your toobox and drag and drop
a timer component to the form. If your writing code in notepad, you need the following code: Friend WithEvents Timer1 As System.Timers.Timer Me.Timer1 = New System.Timers.Timer ' in your constructor martin1 wrote: Show quoteHide quote > is this import correct to add Timer component? > Imports System.Timers > > "Ahmed" wrote: > > > You need to add a timer component to the form. > > > > martin1 wrote: > > > Hi, Ahmed, > > > > > > when run yuor code, get error messgae "Handles clause requires a WithEvents > > > variable defined in the containing type or one of its base types " from > > > Timer1 below. Any clue? > > > > > > Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As > > > System.EventArgs) Handles Timer1.Tick > > > > > > "Ahmed" wrote: > > > > > > > Private ButtonColor As System.Drawing.Color > > > > Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As > > > > System.EventArgs) Handles Timer1.Tick > > > > If ButtonColor = Color.Red Then > > > > ButtonColor = Color.White > > > > > > > > Else > > > > ButtonColor = Color.Red > > > > End If > > > > Me.Button1.BackColor = ButtonColor > > > > End Sub > > > > > > > > Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As > > > > System.EventArgs) Handles MyBase.Load > > > > > > > > ButtonColor = Color.Red > > > > Me.Button1.BackColor = ButtonColor > > > > Me.Timer1.Interval = 1000 ' 1 sec > > > > Me.Timer1.Start() > > > > End Sub > > > > > > > > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As > > > > System.EventArgs) Handles Button1.Click > > > > Me.Timer1.Stop() > > > > ButtonColor = Color.Red > > > > Me.Button1.BackColor = ButtonColor > > > > End Sub > > > > > > > > I tried it in VS 2005. > > > > > > > > Ahmed > > > > martin1 wrote: > > > > > I tried and it doesn't work, any sample code? Thanks > > > > > > > > > > "Herfried K. Wagner [MVP]" wrote: > > > > > > > > > > > "martin1" <mart***@discussions.microsoft.com> schrieb: > > > > > > > how to flash button with 2 color( eg. red and white)? then when user click > > > > > > > button, the button stop flash and stay red color? > > > > > > > > > > > > You may want to use a timer component ('System.Windows.Forms.Timer') and use > > > > > > the timer to set the button control's 'BackColor' property to the desired > > > > > > color. > > > > > > > > > > > > -- > > > > > > M S Herfried K. Wagner > > > > > > M V P <URL:http://dotnet.mvps.org/> > > > > > > V B <URL:http://classicvb.org/petition/> > > > > > > > > > > > > > > > > > > > > > > > >
ASP.NET web application - date conversions UK date format?
Building a single EXE file in VB 2005? What errors are not trappable? default in .NET byref or byval? Build Failed - 0 Errors Adding ActiveX controls at runtime and threading DataGridView row background color How to gain access to objet in different class ? Define a compilation switch Listbox help |
|||||||||||||||||||||||