473,385 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Button Event Handler

I’ve come across an unusual situation tonight, so I’m going to see if anyone
can give me an explanation for what could be going on here.

I created a new form based on instructions from a Microsoft Press book.
Rather than create the entire form (visually), I decided to copy and paste
all the controls from the training sample to my sample. Then, after words, I
entered all of the form’s code. Now, there are two buttons on the form. In
the form’s code module I found an event for one of the buttons. Anyway, I ran
the project anyway without adding any code to the btnClose button. But, when
I clicked on the close button the form closed. Now, this puzzles the heck out
of me. How can my form close when the form’s event modules do not include a
click event or any other event associated with the close button? If fact,
there’s no CLOSE command anywhere in the form’s code at all.

Does anyone have an explanation why something like this could happen?

I know this you might think this can’t be, but its happening and it makes no
sense to me. I’m assuming there must be a way to embed code in a control that
is not visible in the code editor?

I also set a breakpoint on every single line of code in the form and still,
the close button closes the form. Plus, I added an event handler to the click
event to display a message and it worked, but still closed the form. This
makes no sense to me and how can this be possible.

Oct 20 '07 #1
4 1560
On Oct 19, 10:55 pm, Greg <AccessVBA...@newsgroups.nospamwrote:
I've come across an unusual situation tonight, so I'm going to see if anyone
can give me an explanation for what could be going on here.

I created a new form based on instructions from a Microsoft Press book.
Rather than create the entire form (visually), I decided to copy and paste
all the controls from the training sample to my sample. Then, after words, I
entered all of the form's code. Now, there are two buttons on the form. In
the form's code module I found an event for one of the buttons. Anyway, I ran
the project anyway without adding any code to the btnClose button. But, when
I clicked on the close button the form closed. Now, this puzzles the heck out
of me. How can my form close when the form's event modules do not include a
click event or any other event associated with the close button? If fact,
there's no CLOSE command anywhere in the form's code at all.

Does anyone have an explanation why something like this could happen?

I know this you might think this can't be, but its happening and it makes no
sense to me. I'm assuming there must be a way to embed code in a control that
is not visible in the code editor?

I also set a breakpoint on every single line of code in the form and still,
the close button closes the form. Plus, I added an event handler to the click
event to display a message and it worked, but still closed the form. This
makes no sense to me and how can this be possible.
Hmmm... My guess is that the from is shown using form.showdialog, and
the close buttons DialogResult property is set?

Am I close?

--
Tom Shelton

Oct 20 '07 #2

default button and dialog result property`s i use this handy feature to
let my user close a dialog with a enter strike

hth

Michel

"Greg" <Ac**********@newsgroups.nospamschreef in bericht
news:70**********************************@microsof t.com...
I've come across an unusual situation tonight, so I'm going to see if
anyone
can give me an explanation for what could be going on here.

I created a new form based on instructions from a Microsoft Press book.
Rather than create the entire form (visually), I decided to copy and paste
all the controls from the training sample to my sample. Then, after words,
I
entered all of the form's code. Now, there are two buttons on the form. In
the form's code module I found an event for one of the buttons. Anyway, I
ran
the project anyway without adding any code to the btnClose button. But,
when
I clicked on the close button the form closed. Now, this puzzles the heck
out
of me. How can my form close when the form's event modules do not include
a
click event or any other event associated with the close button? If fact,
there's no CLOSE command anywhere in the form's code at all.

Does anyone have an explanation why something like this could happen?

I know this you might think this can't be, but its happening and it makes
no
sense to me. I'm assuming there must be a way to embed code in a control
that
is not visible in the code editor?

I also set a breakpoint on every single line of code in the form and
still,
the close button closes the form. Plus, I added an event handler to the
click
event to display a message and it worked, but still closed the form. This
makes no sense to me and how can this be possible.

Oct 20 '07 #3
"Greg" <Ac**********@newsgroups.nospamschrieb:
I created a new form based on instructions from a Microsoft Press book.
Rather than create the entire form (visually), I decided to copy and paste
all the controls from the training sample to my sample. Then, after words,
I
entered all of the form’s code. Now, there are two buttons on the form. In
the form’s code module I found an event for one of the buttons. Anyway, I
ran
the project anyway without adding any code to the btnClose button. But,
when
I clicked on the close button the form closed.
Make sure there is no 'DialogResult' assigned to the button's 'DialogResult'
property. You can check this in the button's property window.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Oct 20 '07 #4
Ok, now that makes a little sense then. I can also see now that there is a
DialogResult property associated with a buttonc control. It seems that if I
set this property to Cancel, it will always close the form, regardless of how
it was opened. Plus, I can just use this property instead of creating a Click
event with me.close in it. Acutally, it seems that I can use any DialogResult
option to close the form.

I can see were this will be a very useful tool.

Thankis everyone.

Greg

"Tom Shelton" wrote:
On Oct 19, 10:55 pm, Greg <AccessVBA...@newsgroups.nospamwrote:
I've come across an unusual situation tonight, so I'm going to see if anyone
can give me an explanation for what could be going on here.

I created a new form based on instructions from a Microsoft Press book.
Rather than create the entire form (visually), I decided to copy and paste
all the controls from the training sample to my sample. Then, after words, I
entered all of the form's code. Now, there are two buttons on the form. In
the form's code module I found an event for one of the buttons. Anyway, I ran
the project anyway without adding any code to the btnClose button. But, when
I clicked on the close button the form closed. Now, this puzzles the heck out
of me. How can my form close when the form's event modules do not include a
click event or any other event associated with the close button? If fact,
there's no CLOSE command anywhere in the form's code at all.

Does anyone have an explanation why something like this could happen?

I know this you might think this can't be, but its happening and it makes no
sense to me. I'm assuming there must be a way to embed code in a control that
is not visible in the code editor?

I also set a breakpoint on every single line of code in the form and still,
the close button closes the form. Plus, I added an event handler to the click
event to display a message and it worked, but still closed the form. This
makes no sense to me and how can this be possible.

Hmmm... My guess is that the from is shown using form.showdialog, and
the close buttons DialogResult property is set?

Am I close?

--
Tom Shelton

Oct 20 '07 #5

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

Similar topics

4
by: yfng | last post by:
In a web form, I want the user clicks on one button and this button will trigger another button/link which will open a new browser window? How to do that? Is there any method like...
5
by: RAJ | last post by:
hi plz tell me how to know "how window is going to close"... i have to right code for X button of forms... plz telll me thanks bye
1
by: Jim Witt | last post by:
Ref: Win2000, .NET 1.1 Is it possible to set up a series of buttons, and when each is clicked it passes a parameter (MyButton.Text is fine) to a single event handler shared by all the buttons? ...
3
by: Shimon Sim | last post by:
I put linkbutton in a repeater header. I attached event handler in makeup as onclick="btnSort_Click". Made btnSort_Click method public. It doesn't fire if I click on it. I tried to attach it in...
7
by: MgGuigg | last post by:
Hello all, This is my first time posting a question to this forum, so here is hoping I am following protocol. I am scraping the rust off my old Basic programming skills, and have just recently...
15
by: Oleg Subachev | last post by:
I need to programmatically invoke from other class Click event of the Button on my Form. Button.OnClick method is protected, not public. How to perform this ? Oleg Subachev
6
by: Joseph Geretz | last post by:
I'm porting a C# Outlook Addin originally engineered as a COM Addin over to use VSTO. I've gotten this to the point where my VSTO Addin installs its Menu items and Toolbar buttons when Outlook...
11
by: bill | last post by:
I dynamically create buttons and associate them with an event using AddHandler. I want all the button events to fire at one time, when the page is posted, instead of when each button is clicked....
2
by: moondaddy | last post by:
I have an asp.net 2.0 application and put a html button on a web page. I double clicked on the button and it crated the event handler for me and created the stub js function for it like this: ...
17
by: Eric | last post by:
I'm new to JavaScript and I wrote this code to play with. Oddly, if I enter text in a box and then press the button, I only get the onChange event for the text box and not the button's onclick...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.