is it possible to make a picturebox the acceptbutton?
i tried this in form load
Dim picturebox1 As New Button Me.AcceptButton = picturebox1
is there a way i could do this?
So wait. When the use presses the Enter key, what do you want to have happen?
A bit confusing to understand, but since an Accept Button is like a Submit button on a Form, pressing the Enter key in any of the fields should press the Submit Button, in this case a PictureBox.
If so, see if the following code sample helps.
'//--------- Pre-requisites: 1 PictureBox, 3 TextBoxes. ---------\\ Public Class Form1 Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click MsgBox("PictureBox Clicked.", MsgBoxStyle.Information) End Sub '// use one event for multiple controls. Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) _ Handles TextBox1.KeyUp, TextBox2.KeyUp, TextBox3.KeyUp If e.KeyCode = Keys.Enter Then PictureBox1_Click(sender, e) '// call the event procedure. End Sub End Class
So you want to raise the Picturebox1.Click event when the user presses the enter key?
Why not make a hidden button, make it your "accept button" and then use the following code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click PictureBox1_Click(sender, e) End Sub
Or just put the image in the .Image property of the button and clean the .text.
Resize the button to the image size.
Hope this helps
ahhh ok! you guys are smart! XD i didnt think about making a hidden button. good simple fix. its not important im just bored and made a stylish button using a picturebox.
EDIT-- the hidden button didnt work, but i followed code orders code and trigged the picturebox when enter key was pressed when the textbox has focus
Edited by eikal: n/a
My question is how to code search in combobox each time typeing a letter. And the search result in DropDown have to show list items which contains letter or ...
SO Basically i have this problem with this test build of a little project im rewriting and so far its not looking to good
I have multiple tables that are ...
Provides a secure frontend object with restricted access to attributes of the backend object.