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
I want to write out a DXF file with line arc and maybe spline.
My issue is documentation; While I have looked at AutoCAD's site I feel that there isnt ...
How to connect device scanner with visual basic, its analogy I made button scan in vb and typing button scan in press scanner live and walk .. how? Help ...
For Each ctrl As Control In Me.Controls("pnlMainPanel").Controls If ctrl.GetType Is GetType(System.Windows.Forms.Panel) Then For Each subCtrl As Control In ctrl.Controls If subCtrl.GetType Is GetType(System.Windows.Forms.TextBox) Then MsgBox(subCtrl.Text) End If If subCtrl.GetType Is ...