Doggo120 Posted April 27, 2012 Posted April 27, 2012 Its me again! I was trying to find everywhere how to hold down some key (for example, "M") and animate a Button so that it looks that it's "pressed". When I release "M" then the button will be released as well (as if I have clicked the button with the key) Button.PerformClick does not show this. In VB6 there was a Value property, which made this possible... Thanks!!! Quote
dotnetguy37 Posted April 27, 2012 Posted April 27, 2012 Re: Altering Button down state ("pressed") with key Have you tried: Private Sub Button1_KeyDown(ByVal sender As Object, _ ByVal e As System.Windows.Forms.KeyEventArgs) Handles Button1.KeyDown If e.KeyCode = Keys.M Then 'MsgBox("do something") e.Handled = True Button1.FlatStyle = FlatStyle.Flat End If End Sub Private Sub Button1_KeyUp(ByVal sender As Object, _ ByVal e As System.Windows.Forms.KeyEventArgs) Handles Button1.KeyUp e.Handled = True Button1.FlatStyle = FlatStyle.Standard End Sub Quote
Doggo120 Posted April 27, 2012 Author Posted April 27, 2012 Re: Altering Button down state ("pressed") with key I'll try! thanks in advance! Quote
Doggo120 Posted April 27, 2012 Author Posted April 27, 2012 Re: Altering Button down state ("pressed") with key Ok, I tried it... it's ok, but I would like to see the 'real' button pressed state (because it changes very drastically from a Button to a square) Quote
Leaders snarfblam Posted April 27, 2012 Leaders Posted April 27, 2012 Re: Altering Button down state ("pressed") with key You could use a CheckBox control, setting the Appearance property to "Button." It will look like a normal button, but when the Checked property is set to true, the button will appear to be pressed in. You might want to set AutoCheck to false. Otherwise the button will toggle between pushed and raised when the user clicks on it. Quote [sIGPIC]e[/sIGPIC]
Doggo120 Posted April 27, 2012 Author Posted April 27, 2012 Re: Altering Button down state ("pressed") with key Thanks both of u guys, the checkbox is an awesome solution :D Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.