473,503 Members | 1,768 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB.Net - Weird Happenings - Its Freakin Me Out

Using VS.Net 2003 (VB.Net)
WinForm App....

Problem:
I have a form (lets call it Form1)
On Form1 (amongst other things) is a button (btnOne) and an text box
(txtBox).
.....Click on button... Shows another form (lets call it Form2)...
.....All OK so far...
......Close Form2
...Back to Form1...btnOne has focus... All Ok so far...
...Select txtBox... btnOne appears to lose focus (lost focus event fires)
... txtBox appears to gain focus (gotFocus event fires)...
.... type something in txtBox Press <CR>
.... Form2 Shows (onLoad event Fires)
... Problem .... This is not the desired result...
.... Close Form2
.... btnOne has focus
.... Select txtBox ... btnOne loses focus...text box has focus
.... Type something in txtBox ... Press <<CR>
.... This time every thing works as it should and txtBox reacts to the <CR>
keypress...

Question: Why does btnOne appear not to lose focus the first time.

And.. Yes... If I select btnOne and select Form2 again then everything
starts over....

What have I done??
Any help appreciated...
Regards...

Jul 21 '05 #1
3 1280
What you will find is that on form1 you have a property call AcceptButton
what you will find is that this property has btnOne set to it. So when you
press <CR> that button will run. So if you don't want it to run then change
the AcceptButton property not to be any button.

I hope this helps

Jon
"KeithO" <Ke****@discussions.microsoft.com> wrote in message
news:69**********************************@microsof t.com...
Using VS.Net 2003 (VB.Net)
WinForm App....

Problem:
I have a form (lets call it Form1)
On Form1 (amongst other things) is a button (btnOne) and an text box
(txtBox).
....Click on button... Shows another form (lets call it Form2)...
....All OK so far...
.....Close Form2
..Back to Form1...btnOne has focus... All Ok so far...
..Select txtBox... btnOne appears to lose focus (lost focus event fires)
.. txtBox appears to gain focus (gotFocus event fires)...
... type something in txtBox Press <CR>
... Form2 Shows (onLoad event Fires)
.. Problem .... This is not the desired result...
... Close Form2
... btnOne has focus
... Select txtBox ... btnOne loses focus...text box has focus
... Type something in txtBox ... Press <<CR>
... This time every thing works as it should and txtBox reacts to the <CR>
keypress...

Question: Why does btnOne appear not to lose focus the first time.

And.. Yes... If I select btnOne and select Form2 again then everything
starts over....

What have I done??
Any help appreciated...
Regards...

Jul 21 '05 #2
Just to add to Jon's answer:

Your form thinks that you want the button to be a default button, and that
it should fire when you press CR.
This is a feature. Most dialog boxes have "default buttons" (usually
labeled something like OK or Next).
This feature is used to indicate which button you want to be the default
button.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"KeithO" <Ke****@discussions.microsoft.com> wrote in message
news:69**********************************@microsof t.com...
Using VS.Net 2003 (VB.Net)
WinForm App....

Problem:
I have a form (lets call it Form1)
On Form1 (amongst other things) is a button (btnOne) and an text box
(txtBox).
....Click on button... Shows another form (lets call it Form2)...
....All OK so far...
.....Close Form2
..Back to Form1...btnOne has focus... All Ok so far...
..Select txtBox... btnOne appears to lose focus (lost focus event fires)
.. txtBox appears to gain focus (gotFocus event fires)...
... type something in txtBox Press <CR>
... Form2 Shows (onLoad event Fires)
.. Problem .... This is not the desired result...
... Close Form2
... btnOne has focus
... Select txtBox ... btnOne loses focus...text box has focus
... Type something in txtBox ... Press <<CR>
... This time every thing works as it should and txtBox reacts to the <CR>
keypress...

Question: Why does btnOne appear not to lose focus the first time.

And.. Yes... If I select btnOne and select Form2 again then everything
starts over....

What have I done??
Any help appreciated...
Regards...

Jul 21 '05 #3


"Nick Malik [Microsoft]" wrote:
Just to add to Jon's answer:

Your form thinks that you want the button to be a default button, and that
it should fire when you press CR.
This is a feature. Most dialog boxes have "default buttons" (usually
labeled something like OK or Next).
This feature is used to indicate which button you want to be the default
button.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"KeithO" <Ke****@discussions.microsoft.com> wrote in message
news:69**********************************@microsof t.com...
Using VS.Net 2003 (VB.Net)
WinForm App....

Problem:
I have a form (lets call it Form1)
On Form1 (amongst other things) is a button (btnOne) and an text box
(txtBox).
....Click on button... Shows another form (lets call it Form2)...
....All OK so far...
.....Close Form2
..Back to Form1...btnOne has focus... All Ok so far...
..Select txtBox... btnOne appears to lose focus (lost focus event fires)
.. txtBox appears to gain focus (gotFocus event fires)...
... type something in txtBox Press <CR>
... Form2 Shows (onLoad event Fires)
.. Problem .... This is not the desired result...
... Close Form2
... btnOne has focus
... Select txtBox ... btnOne loses focus...text box has focus
... Type something in txtBox ... Press <<CR>
... This time every thing works as it should and txtBox reacts to the <CR>
keypress...

Question: Why does btnOne appear not to lose focus the first time.

And.. Yes... If I select btnOne and select Form2 again then everything
starts over....

What have I done??
Any help appreciated...
Regards...

Thanks for the responses..


Sorry... Should have mentioned I checked the AcceptButton Property of the
form and this was/is set to 'None'

My work round at the moment is to set focus to the text box prior to
displaying the form in the button_click event....

This has fixed the problem but why I have to do this is frustrating...

Regards...KeithO

Jul 21 '05 #4

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

Similar topics

2
2347
by: Gabriel Afana | last post by:
I have a simple php script to just send email.....When I first load the script in a browser...it sends 2 emails. Why?? The weird thing is then when I refresh the page, it send only one email...I...
3
2068
by: redneck_kiwi | last post by:
Hi all: I have a really weird problem. I am developing a customer catalog system for my company and as such have delved into sessions for authentication and access levels. So far, I have managed...
13
3777
by: Wolfgang Kaml | last post by:
Hello All, I have been researching newsgroups and knowledgebase all morning and not found a solution that would solve the problem I have. I am having an ASP or ASPX web page that implement a...
0
1423
by: LRW | last post by:
I manage our mySQL database through putty (SSH terminal client). And whenever I do a select * from the table that contains ENCODEd passwords, the funky characters do funky things with the display....
2
1982
by: jwbeaty | last post by:
Here's a weird one. I'm running SQL Server 7 and when I run a backup something weird happens. When I perform the backup via Enterprise Manager by right clicking on the database I want to...
1
2076
by: Kaneda | last post by:
Hello everyone! I have some weird(?) problems, and I am not quite sure if there are due to my errors or maybe a limitation in the .Net framework. I have a ComboBox I need to fill with the...
82
5284
by: nobody | last post by:
Howdy, Mike! mikecoxlinux@yahoo.com (Mike Cox) wrote in message news:<3d6111f1.0402271647.c20aea3@posting.google.com>... > I'm a C++ programmer, and have to use lisp because I want to use >...
1
1121
by: Chris | last post by:
Hey, I have a DataGrid that allows for a combobox in a column through a inherited DataGridColumnStyle and a inherited ComboBox. I have 3 of these columns in a row. The overall problem is that...
3
5443
by: aling | last post by:
Execute following T-SQL within Queary Analyzer of SQL Server 2000: ======================================= DECLARE @dTest DATETIME SET @dTest='2001-1-1 1:1:1:991' SELECT @dTest SET...
0
1812
by: P Pulkkinen | last post by:
Dear all, sorry, i know this code is far little too long to debug here, but there is really annoying logical error. If someone debugs this, I really offer warm virtual handshake. What this...
0
7199
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,...
0
7274
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,...
0
7323
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6984
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7453
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...
0
5576
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,...
0
3162
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3151
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
732
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.