473,797 Members | 3,204 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem with Autocomplete and Leave focus event

I made a simple app to test Leave focus event and AutoComplete
functionality on the text box control. I added 2 text box controls on
the blank form. Then I added Leave focus event handlers for these text
boxes, set AutoCompleteMod e property to SuggestAppend and
AutoCompleteSou rce property set to CustomSource.
AutoCompleteCus tomSource property is changed in a Leave focus event
handlers for each text box, see code below. When I run the application
and changed focus with TAB key, focus still stood on the first text
box. Simply said, it is impossible to change focus with TAB key. Any
suggestions how to solve this problem?

public partial class Form1 : Form
{
AutoCompleteStr ingCollection textBox1AutoCom pleteCollection =
new AutoCompleteStr ingCollection() ;
AutoCompleteStr ingCollection textBox2AutoCom pleteCollection =
new AutoCompleteStr ingCollection() ;

public Form1()
{
InitializeCompo nent();
}

private void InitializeAutoC omplete()
{
textBox1AutoCom pleteCollection .Clear();
textBox2AutoCom pleteCollection .Clear();

textBox1AutoCom pleteCollection .Add("Sunday");
textBox1AutoCom pleteCollection .Add("Monday");
textBox1AutoCom pleteCollection .Add("Tuesday") ;
textBox1AutoCom pleteCollection .Add("Wednesday ");
textBox1AutoCom pleteCollection .Add("Thursday" );
textBox1AutoCom pleteCollection .Add("Friday");
textBox1AutoCom pleteCollection .Add("Saturday" );

textBox2AutoCom pleteCollection .Add("Peter");
textBox2AutoCom pleteCollection .Add("John");
textBox2AutoCom pleteCollection .Add("Martin");
textBox2AutoCom pleteCollection .Add("George");

textBox1.AutoCo mpleteCustomSou rce =
textBox1AutoCom pleteCollection ;
textBox2.AutoCo mpleteCustomSou rce =
textBox2AutoCom pleteCollection ;
}

private void Form1_Load(obje ct sender, EventArgs e)
{
InitializeAutoC omplete();
}

private void textBox1_Leave( object sender, EventArgs e)
{
InitializeAutoC omplete();
}

private void textBox2_Leave( object sender, EventArgs e)
{
InitializeAutoC omplete();
}
}
Jan 11 '08 #1
0 1660

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

Similar topics

13
2799
by: Mr. B | last post by:
Here's the situation... You've a combobox with Items already added. Say they look like this (or even lines of text): 10-00-232 10-00-256 10-01-006 10-01-213 10-02-200
1
3295
by: Chris Mayers | last post by:
Hi, I have an application that has (for the sake of argument) 2 (MDI) windows open. If I click into a textbox on FormA then the 'Enter' event for that TextBox fires, great! However, if I then click on FormB, then back to FormA although the cursor is still flashing in the same textbox on FormA, when I tab out, the 'Leave' event for that TextBox does not fire. If I stay on FormA and Shift-Tab back into the textbox then the 'Enter' event...
2
6161
by: JayDee | last post by:
After a user enters data into a field, I need to populate other controls on the form, based on the user entry. I have to use either Leave, Validating or Validated, and I take it I can't use LostFocus because there is no selection for that event in the dropdown list on the code page. What's happening is that all 3 events mentioned above for the textbox control fire in the proper order when the form is invoked, but don't fire the first time...
2
21268
by: vooose | last post by:
Does anyone know the difference between these two? The doc for LostFocus says 'Occurs when the control loses focus.' whereas for Leave it says 'Occurs when the input focus leaves the control' The doc also states that for controls losing focus you should use Leave, so I do. Another reason I used it is because comboBox.LostFocus event
8
3378
by: moondaddy | last post by:
I have a form for entering a user's address and all fields have a required validating control associated with them and the error msg for each field displays right next to it. The normal behavior is that the error msg doesn't show unit the use hits the submit button or the user enters data and moves the focus to another control so the field becomes dirty. So far so good. Now when the user goes back to that control and starts to input data...
1
2055
by: melanieab | last post by:
Hi again, I have a textbox where the text is longer than the textbox width. When I type something in there or even do any single keystroke (other than tab, up, down, or enter) and then leave, the beginning of the string shows, and focus goes on to the next box. But if I just tab through or want to go straight to the next textbox, the beginning of the string is cut off, leaving the end of the string visible. More info that may/may not be...
1
3855
by: wkerplunk | last post by:
Below is what I have build with several different languages. It works great but I need help, I am stuck. When you click on an item in the dropdown autocomplete div it does a mousedown function and send the item number to the xmlHttp and works awesome. Now I need to add an apply button next to it. so they can type in the complete number then hit apply and it does the same function. I cant get it to work with the script I have. The image...
0
1824
by: =?Utf-8?B?QWJoaQ==?= | last post by:
Hi All, i have 3 textboxes for area Code,phone number and Extention and each have MaskedEditExtender associated with it. i want that when the length of first text box reaches it's maxlength , focus will be set to next textbox automatically, means i want auto tabbed fields. for which i created java script function and associated it with OnKeyDown and OnKeyUp event of TextBox. but it's not working and when i remove the...
5
3371
by: Pat | last post by:
Hi ASP Gurus, Please help me. Autocomplete works fine when the control does not have the focus when the page load. But when I put the focus on page load, then autocomplete does not work. I even tried javascript pageload code, but with no success. <script language ="javascript" type ="text/javascript" > function focusIt() { //alert('test'); var mytext =
0
9685
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
10246
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
10209
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
9066
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
7560
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
5459
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
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4135
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3750
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.