473,657 Members | 2,592 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Code for Button Click Event

I have code that I want to run so that if the result is true, it changes the
current button's ".DialogRes ult" property to "DialogResult.O K". Problem is,
when I run this code on the ".Click" event for the current button and then
run this code, if the ".DialogRes ult" property is change, it does not take
affect until the button is pressed again.

I do I workaround this?
Nov 20 '05 #1
11 10997
"Sarah" <sa********@pow ertechcanada.co m> schrieb
I have code that I want to run so that if the result is true, it
changes the current button's ".DialogRes ult" property to
"DialogResult.O K". Problem is, when I run this code on the ".Click"
event for the current button and then run this code, if the
".DialogRes ult" property is change, it does not take affect until the
button is pressed again.

I do I workaround this?


Why don't you execute the code on the first click?
--
Armin

Nov 20 '05 #2

Why don't you execute the code on the first click?


I am executing the code on the buttons "click" event. When the code
evaluates to true, it changes the current buttons control ".DialogRes ult"
property to ".DialogResult. OK". The problem is, when I change this setting
in this buttons click event, the change does not take place right away -
i.e. since the button was already pressed, changing the property of it after
it is pressed is not having the desired result -- which is to change the
".DialogRes ult" property was this click event. (The .DialogResult.O K
property change only works for the next time the button is pressed_).

Any help would be appreciated to find out how to run code to change the
..DialogResult property so that the change would change the behavior of the
button right away.

Thanks.
Nov 20 '05 #3
"Sarah" <sa********@pow ertechcanada.co m> schrieb

Why don't you execute the code on the first click?


I am executing the code on the buttons "click" event. When the
code evaluates to true, it changes the current buttons control
".DialogRes ult" property to ".DialogResult. OK". The problem is, when
I change this setting in this buttons click event, the change does
not take place right away - i.e. since the button was already
pressed, changing the property of it after it is pressed is not
having the desired result -- which is to change the ".DialogRes ult"
property was this click event. (The .DialogResult.O K property change
only works for the next time the button is pressed_).

Any help would be appreciated to find out how to run code to change
the .DialogResult property so that the change would change the
behavior of the button right away.


Whenever I change the dialogresult property it does change right away.
--
Armin

Nov 20 '05 #4

Whenever I change the dialogresult property it does change right away.

This is my scenerio:

- I launch a dialog box (form 2) from form 1 using "Dialog_AddName _Results =
CustomerName.Sh owDialog()"
- On the dialog box, the "Add" button "DialogResu lt" property is set to
"None" by default
- On the "Add" button click event, some code evaluates to true or false
- If the above code evaluates to true, it sets "DialogResu lt" to OK (1)

The thing is, the dialog box does not close up right away - as when the
"Add" button was first pressed, the "DialogResu lt" was set to "None"

Hope that gets you to the point where I am. Is there an event that I can run
before the click event of the button that will run when the button is
clicked?
Nov 20 '05 #5
Why don't you just set the Form.DialogResu lt property in your button, then
close the form?
(Read that in the SDK.... but you may just "Hide" the form, closing it may
free the resources)

"Sarah" <sa********@pow ertechcanada.co m> wrote in message
news:xn******** *************@n ews2.telusplane t.net...

Whenever I change the dialogresult property it does change right away.

This is my scenerio:

- I launch a dialog box (form 2) from form 1 using "Dialog_AddName _Results

= CustomerName.Sh owDialog()"
- On the dialog box, the "Add" button "DialogResu lt" property is set to
"None" by default
- On the "Add" button click event, some code evaluates to true or false
- If the above code evaluates to true, it sets "DialogResu lt" to OK (1)

The thing is, the dialog box does not close up right away - as when the
"Add" button was first pressed, the "DialogResu lt" was set to "None"

Hope that gets you to the point where I am. Is there an event that I can run before the click event of the button that will run when the button is
clicked?

Nov 20 '05 #6
Dont set the DialogResult property on the button, set it on the form, then
as I said, close or hide the form.

"Sarah" <sa********@pow ertechcanada.co m> wrote in message
news:xn******** *************@n ews2.telusplane t.net...

Whenever I change the dialogresult property it does change right away.

This is my scenerio:

- I launch a dialog box (form 2) from form 1 using "Dialog_AddName _Results

= CustomerName.Sh owDialog()"
- On the dialog box, the "Add" button "DialogResu lt" property is set to
"None" by default
- On the "Add" button click event, some code evaluates to true or false
- If the above code evaluates to true, it sets "DialogResu lt" to OK (1)

The thing is, the dialog box does not close up right away - as when the
"Add" button was first pressed, the "DialogResu lt" was set to "None"

Hope that gets you to the point where I am. Is there an event that I can run before the click event of the button that will run when the button is
clicked?

Nov 20 '05 #7
"Sarah" <sa********@pow ertechcanada.co m> schrieb

Whenever I change the dialogresult property it does change right
away.

This is my scenerio:

- I launch a dialog box (form 2) from form 1 using
"Dialog_AddName _Results = CustomerName.Sh owDialog()"
- On the dialog box, the "Add" button "DialogResu lt" property is set
to "None" by default
- On the "Add" button click event, some code evaluates to true or
false - If the above code evaluates to true, it sets "DialogResu lt"
to OK (1)

The thing is, the dialog box does not close up right away - as when
the "Add" button was first pressed, the "DialogResu lt" was set to
"None"

Hope that gets you to the point where I am. Is there an event that I
can run before the click event of the button that will run when the
button is clicked?


I still don't understand. Why don't you simply put

If <evaluationIsTr ue> Then
Me.DialogResult = Dialogresult.Ok
Me.Close
End If

in the button's click event? Now you don't have to click twice.
--
Armin

Nov 20 '05 #8
Then, the calling form does not get the information via :

"Dialog_AddName _Results = CustomerName.Sh owDialog()"


Nov 20 '05 #9
Yes it does, Armin is right. The result you get from ShowDialog is the
result that's currently in the Form's DialogResult property, so, in your
button click event, do this:

Me.DialogResult = DialogResult.OK
Me.Close

The returned value will be DialogResult.OK , and the form will close.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Maybe it's a game called 'Punish the User'"
"Sarah" <sa********@pow ertechcanada.co m> wrote in message
news:oo******** *************@n ews2.telusplane t.net...
Then, the calling form does not get the information via :

"Dialog_AddName _Results = CustomerName.Sh owDialog()"

Nov 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
1324
by: Mathew Hill | last post by:
I am a beginner to the more technical aspects of Microsoft Access (2000) and was wondering if any one can help. I have 3 buttons on a form which add, delete and search for a record. However, when I click on the respective buttons absolutely nothing happens! I was wondering if anyone could help? The code I have is below... ADDING A RECORD Private Sub cmdaddstudent_Click() On Error GoTo Err_cmdaddstudent_Click
6
3936
by: Sally | last post by:
I need to be able to click in a subform and run code but at the same time I need to be able to scroll the records without running the code. I tried coding the Enter event of the subform control but when I try to scroll the records the code runs. The subform is continuous; all the controls are on one line and the detail section is not exsposed above or below the controls. I tried coding the detail Click event but nothing happened. I tried...
1
2331
by: Stephen | last post by:
Hey Everyone, I have a problem with a web application due to the use of both client-side and server side script on the on-click event of a button. The client side script runs first as expected however my problem is that this code runs and brings up a Microsoft Internet Explorer Window telling the user they are going to be charged for the search they are about to do. The user then has to click ok or cancel. My problem with this is that I...
1
2312
by: Stephen | last post by:
Hey All, I have a problem with a web application due to the use of both client-side and server side script on the on-click event of a button. The client side script runs first as expected however my problem is that this code runs and brings up a Microsoft Internet Explorer Window telling the user they are going to be charged for the search they are about to do. The user then has to click ok or cancel. My problem with this is that I need...
3
1361
by: John | last post by:
Hi On my webform, in design mode when I double click on the button component, it creates a click sub for me. But when I add code to the click event and run the web form the code does not seem to be executed. I have verified this by setting break points. Why would clicking the button not execute the click sub in this case? Thanks
1
1484
by: bennett | last post by:
At http://www.brainjammer.com/testing/validator_test.aspx I have a text field where you can enter text, and a button where if you click the button, it sets the value of a label below it, to display the text you entered in a text field. There is also a RequiredFieldValidator for the text field so that you get an error if you leave it blank. As long as I have EnableClientScript set to true for the RequiredFieldValidator, if I leave the...
4
2245
by: Craig831 | last post by:
First off, I apologize if this gets long. I'm simply trying to give you all enough information to help me out. I'm writing (almost finished, actually), my first VB.Net application. It's a forms application that is going to be used to extract data from a legacy system (VSAM based mainframe file structure), and output data in pipe-delimited record layouts, multiple record types per file, one file per chosen client. I have been working on...
4
3500
by: John Boy | last post by:
Hi, Can anyone help. This is really doing my nut in. 3 years ASP exp. and now doing .DOT which is a step in the wrong direction. Basically I am left with the code of a guy who has left. When I click a button on a pop-up window the javascript for that button click does a 'button.form.submit'. On the Server side there is a Button click event for this button, but for some reason it no longer fires. It worked fine before and everything...
21
8140
by: Ben | last post by:
Hello I have frames set up in an asp.net application and need one frame to refresh another. Seeing as events need to be registered at the time the page is sent from the server, I was wondering if I could place a hidden button in a frame that would have the attribute to refresh the other. I would need code to "invoke" the onclick event (ie i need code to click the button). is this possible? thanks.
0
8425
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8326
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8845
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8622
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7355
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5647
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4333
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1973
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1736
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.