473,804 Members | 3,228 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can't seem to get AcceptButton working when changed in code?

Hi,

I have a search for where we want the user to enter the search criteria in
at the top and press enter, then the results are shown in a datagrid which we
set the focus to. Once they select the item they want to choose then they
press enter to accept the form.

The problem is when you go into the form butSearch is set to AcceptButton
for the form, once you have selected the search criteria to populate the data
grid then we want to make butOK the AcceptButton for the form.

The butOK does have the highlight round it to say its the default button but
once you set it in code you can't even click on it with the mouse?

Anyone got any ideas?
Thanks
Mike
May 18 '06 #1
2 1660
sonicm wrote:
Hi,

I have a search for where we want the user to enter the search criteria in
at the top and press enter, then the results are shown in a datagrid which we
set the focus to. Once they select the item they want to choose then they
press enter to accept the form.

The problem is when you go into the form butSearch is set to AcceptButton
for the form, once you have selected the search criteria to populate the data
grid then we want to make butOK the AcceptButton for the form.

The butOK does have the highlight round it to say its the default button but
once you set it in code you can't even click on it with the mouse?

Anyone got any ideas?
Thanks
Mike

Just a suggestion:

Don't have any acceptbutton.
If the user is in the search box, keypress 13 ( <ENTER> ) causes the
search, as well as clicking the search button.
If the user is in the grid, keypress 13 causes accept action, as well as
clicking the accept button.

Tom
May 18 '06 #2
> Just a suggestion:

Don't have any acceptbutton.
If the user is in the search box, keypress 13 ( <ENTER> ) causes the
search, as well as clicking the search button.
If the user is in the grid, keypress 13 causes accept action, as well as
clicking the accept button.

Tom


Yeah I did think of that but thought I'd try to use the AcceptButton as its
neater. Looks like a bug in .NET 2003 then. Ok i'll use they keypress instead.

Thanks for your help
Mike
May 19 '06 #3

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

Similar topics

0
298
by: Kevin Smith | last post by:
I ran across a problem after installing the .NET framework Service Pack 1 on both XP and Server 2003, so I thought I would post the solution here in case anyone else ran across it. After installing the service pack on my development machine, I started getting an ObjectDisposedException every time I hit the enter button while in a TextBox. The top of the call stack said the errant method was System.Windows.Forms.Control.CreateHandle(),...
2
6024
by: lostdreamz | last post by:
Ok, my situation is like this. I have a form with a few text boxes each with a 'validating' event, OK & Cancel buttons, and have the AcceptButton/CancelButton/DialogResult properties all set. Situation 1: (works fine) If the user enters invalid text in a text box, presses Enter in the text box, the validation displays a msgbox. They now correct the text, press Enter in the text box, it validates correctly this time and the
15
4058
by: Adam J. Schaff | last post by:
I have noticed that if a user closes a form via pressing return (either while the OK button has focus or if AcceptButton is set to OK for the form) then the "ENTER" keypress event fires ON THE CALLING FORM! This is very bad for me, because in my application, Form1 responds to an ENTER keypress by calling Form2. If the user closes Form2 via an ENTER, then Form1 just reopens it again, kind of trapping the user in Form2 (they can still close...
1
1788
by: Jeff | last post by:
Hello all. I'm trying to figure out exactly what is going on here. I'm getting different results on different forms, and it's driving me nuts. For example, I have a form called FormFinish. It's AcceptButton is set to btnExport and the CancelButton is set to btnCancel. btnExport on FormFinish has no event code whatsoever (not even for click.) When the user either clicks the button or presses enter on the
1
1857
by: Alien2_51 | last post by:
I have a form with it's AcceptButton property set to a button on my forms click event, when I hit enter in runtime on the form, the cursor goes to an hourglass for a second, as if it were doing something but does not hit the breakpoint I have set, when I press the button the event procedure code executes correctly and the break point is hit, what could be the problem...? TIA Dan
0
1083
by: Karsten Sosna | last post by:
Hello NG, i have a problem with the AcceptButton in VB.Net and C#. I have an empty project with one form. On this form i take two buttons(Button1 and Button2). Now i set the the AcceptButton-Property to Button2, compile the application with the IDE. After the compilation the property is already set to Button2. Now i add a new UserControl to the project and drop it on the Form(AcceptButton = Button2). When i compile the project the property...
1
2481
by: Al Biheiri | last post by:
how do i create an AcceptButton in c# user presses enter on textbox = button1.click something like AcceptButton = button1
1
4784
by: Tony Johansson | last post by:
Hello! I'm reading a book which mentioned about this AcceptButton property for a form which seems quite easy so I try to figure out how it works but I have run into some small problems. I have this small easy program below which show two buttons called button1 and button2. In this program when the Enter key is clicked event handler for button1 is called.
3
1631
by: Josh Kodroff | last post by:
I have a pretty standard Windows Form with 2 relevant buttons: btnOK and btnCancel. I set both buttons' DialogResult properties appropriately. I then set the form AcceptButton and CancelButton properties appropriately. However, whenever I click the Play button, the 2 properties get reset back to their defaults (nothing). Does anyone have any idea why this might be happening? I'm particularly annoyed because I got this right on...
0
9708
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
10589
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
10340
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10327
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9161
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...
1
7625
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6857
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
5527
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.