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 have a folder full of files in pairs (one is a log, another is a DB backup) They are basically create/modified at the same time.
I need ...
Im doing some work with C# and AD and Im missing something right now that I cant seem to see.
I want to get a description of a security group ...
as I'm looking into the MVC pattern, I thought I'd create a small application to understand a bit more.
Let's look at the code:
//model package model; public ...