|
-
Jul 31st, 2003, 02:32 PM
#1
Thread Starter
Addicted Member
Determine if an OK button is clicked
Quick question. Will anyone show me how to determine if a button is clicked or not in a form? I want to determine if an OK button is clicked or not.
Thanks!
ljCharlie
-
Jul 31st, 2003, 02:49 PM
#2
Fanatic Member
When you double click on the control in the design view it will open up the command button's click event.
VB Code:
Private Sub cmdOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOK.Click
MsgBox("Ok button pressed")
End Sub
If wishes were fishes we'd all cast nets.
-
Jul 31st, 2003, 03:01 PM
#3
Thread Starter
Addicted Member
Thanks for the response but here's what I want. Perhaps I should be more precise.
I have two forms, form1 and form2. In form2 I have two buttons, btnCancel and btnOK. In form1, I want to determine if form2.btnOK is clicked or form2.btnCancel is clicked.
ljCharlie
-
Jul 31st, 2003, 10:22 PM
#4
On form2 set btnOk as the AcceptButton and btnCancel as the CancelButton of the form. Then in their click event set the DialogResult to the proper value (ok/cancel) and close the form. Then when you show the form use ShowDialog instead of Show and it will return which button was pressed.
-
Aug 4th, 2003, 08:26 AM
#5
Thread Starter
Addicted Member
Thanks for the help. How do I set the btnOK to AcceptButton and btnCancel to CancelButton?
ljCharlie
-
Aug 4th, 2003, 10:01 AM
#6
AcceptButton and CancelButton are properties of the form, set them there.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|