473,396 Members | 1,770 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,396 software developers and data experts.

Press Enter key, then Combobox clear text, how to stop it ?

Hi,
I use Combobox in DropDownStyle = simple, and AutoCompleteMode, I bind DataSource for Combobox. So I have a Combobox AutoComplete with a list from Database.
When I use in DropDownStyle = DropDownList, it don't have problem.
But when I use it in Simple, when I chose a item by press Enter, Text of Combobox is cleared. I use PreviewKeyDown and set again text for Combobox. But there are 2 times occur this event, and text is set 1 times, then it is cleared.
Please help me solve this problem. Thanks.
I post 4 images. First image is I chose item.
Second image is PreviewKeyDown occur first time.
Third image is set Text of Combobox (it is cleared).
Fourth image is PreviewKeyDown occur again, then Text is cleared.
Attached Images
File Type: jpg untitled1.jpg (17.7 KB, 783 views)
File Type: jpg untitled2.jpg (18.1 KB, 584 views)
File Type: jpg untitled3.jpg (17.4 KB, 504 views)
File Type: jpg untitled4.jpg (16.6 KB, 467 views)
May 1 '12 #1
3 8531
:), I have just find the answer, I add a command, result:
Expand|Select|Wrap|Line Numbers
  1. if (e.KeyValue == 13)
  2.             {
  3.                 if (Combobox.Text != "")
  4.                     StringGlobal = Combobox.Text;
  5.                 if (Combobox.Text == "")
  6.                     Combobox.Text = StringGlobal;
  7.             }
But I use mouse to chose the item, text is cleared.
May 1 '12 #2
RhysW
70
i would say you aren't using the autocomplete properly then if its deleting everything
May 1 '12 #3
I want to create a input (input commands) that it have a function like intellsense. I have found on internet and I found 2 ways: use rich textbox + custom code (harder) and autocomplete combobox.
My combobox (more important properties):
AutoCompleteMode = SuggestAppend
AutoCompleteSource = ListItems
DropDownStyle = Simple
DataSource = MyDataBindingSource
My combobox display a list of commands. When user type, it show commands follow character is typed.
If who can have a solution for my problem, I thank you.
May 1 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: JCO | last post by:
How's come when I press the enter key, I can't get it to execute the correct password. It seems that I'm forced to press the button. I want to be able to do both. How is this done?
4
by: penny336 | last post by:
hi here is my original// it can convert to upper case or lower case but require user press "enter" how to implement a without "press enter" version e.g. if input 'a' --> at commad prompt will show...
5
by: junk mail | last post by:
My friend is trying to code a small c program where he wants to force the user to press enter and only enter to continue. Currently he is using getchar() with a loop but you can type any number...
0
by: Lalit Bhatia | last post by:
I have a problem while using Enter key in text box. when user presses enter in the text box information of customer is loaded. and I have a clear button that clears all the controls on the form....
1
by: Mamatha | last post by:
Hi I have a samll application. In that i have one textbox and one button. When i enter some text in text box and press enter then the button will have a focus. How can i do this? Mamatha
11
by: dhirajpriya | last post by:
hi everyone when i create single text box on page and press enter the page refresh how can i stop to refresh the page.... dhiraj
5
by: hmkaddoura | last post by:
Hi All, in my form I have two textboxes (T1,T2) and two buttons (B1,B2) how can i insert text in T1 and press enter to execute B1 event, and insert text in T2 and press enter to execute B2...
1
by: RyanT | last post by:
Access 2000 Windows XP I have a small form with two text boxes: - User ID - Password The form also has two command buttons: - Login - Cancel
1
by: daonho | last post by:
I tried to use javascript to trigger up the button click function when user press enter key from the textbox. This function work fine with a single button click such has login page. However, if the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
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
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...
0
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
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,...

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.