c# combobox drop down click deletes everything in textbox - c#

I have a windows program (.NET 4.5) that has a combobox with custom dropdown data. My autocomplete type is set to AppendSuggest, so that the customer can easily type in a name, press tab or enter, and then move on to the next box to fill in.
When the combobox loses focus (goes to another control), the program will parse the text in the textbox. If the name exists in the database, it will attach that person to this instance, otherwise it will create a new person with the name (properly cased) in the database.
Pressing tab allows the autocomplete box to fill in the remaining text and it successfully attaches it to the database. However, if the enter button is pressed or, more importantly, the customer tries to click on a user from the autocomplete drop down list, the textbox simply deletes all text in it and moves on to the next box with nothing in it.
I can't find out how to intercept the data that the user clicks. Ideally, I just want the user to click an item from the dropdown list and have it fill the text in, then parse that text and move on.
I have also checked my code and there is no where in the code that deletes the text from this combobox. It seems to be happening by itself behind the scenes.
Also, I am a somewhat advanced programmer in C#, and although I really haven't worked with autocomplete, I am baffled that I am stumped on something as simple as this.

Related

Dynamically Creating Textboxes and DropDown Boxes for input form

I am working on a Nutrition Program that would allow a user to enter in the nutrition information for a item.
this is what my input form looks like every time a user clicks the plus button I need to create three new text boxes and a drop down box which would look like the above example.
This is what I am using right now but it only creates the textboxes for the first click. I need create the textboxes and combo boxes on every time the user clicks the add button.
Nvm,
I managed to do this myself using ViewStates it took alot of code but it works this is adding the controls on button click.
This is re-adding the controls on postback
And this is the results

Highlight certain controls when hovering above a button

I have the following case:
There are several list boxes where the user can select something, some text boxes to enter text and several buttons to execute commands.
If a button is not enabled (due to a wrong/missing selection in a list box and/or a wrong entry in a text field), I'd like to show the red error adorner around the elements that needs to be fixed.
I know how I can show the red border when a entry is not correct using Validation rules - but they are not applicable since the fact "is correct" depends on the command the user wants to execute. E.g. to add an element, there is no need for a selected element in a listbox, but if you want to delete one, there needs to be a selected one.
You should use an attached behavior on the button itself. Then, hook the MouseEnter and MouseLeave events for the button.
Then all you have to do (when the mouse enters and exits the button) is fill out the validation rules for each control you want to "turn on or off" for the validation box.

How to distinguish modified item in binding list?

I am developing a windows application using C# and .net 4.5 under visual studio 2013 IDE.
In my application when the user attempt to enter a new data the program creates an object of appropriate class let's call the class DataClass and the to be objectOfDataClass.
The objectOfDataClass is added to a BindingList<DataClass> let it be bindingListOfDataClass which is bounded to a DataGridView as a data viewer.
The user enters data in a text boxes then he/she press a button to add text boxes value as a list item to bindingListOfDataClass and then he/she can view all data records on the DataGridView.
Then the user has a choice to click save button to save the data to a file or database.
All of these functions are working very well without any problem. But I want to add another function to mark or distinguish the new data entry or the modified cells on the datagridview and the bindingList by changing the style format of that cell (i.e: changing the background color or font style ..etc) before the user click the save button so he/she is notified to confirm any changes before saving the new entries.
The comparison should be between the saved data (the data on the file or database) and the data shown in the datgridveiw.
Now I am looking for a best solution which must achieves higher performance and preserve memory. so any suggestion please?
Exactly here you need to distinguish newly added items and already saved items
from the list So you can easily use flag for this....
When you click on Add Button you can false your flag & then true..Before items saved you can change color or something else where flag false..

How can I load data when I click in another box?

I have an autocomplete on my page where I use it as a search. I want to be able to select an item that appears in the autocomplete and then when the user clicks another box it will do a postback and if there is data for the one selected, it will populate the other fields for that chosen selection.
So what I am asking, is how would I go about doing a postback when the user clicks into another textbox on the screen?
Hi you could use event from textbox (TextChanged) inside this event put your code to verify if this data is correct. Don't forget put property AutoPostBack from textbox in True. This action only can be use if the data in textbox change if for example you put
My Dog
and data not exists if you change focus nothing will happen until you change the data for example
My Cat

WinRT - Programmatically tab to next control in C# code behind

Once I successfully validate user data in a TextBox (using TextChanged EventHandler), I'd like to programmatically tab to the next input control. I know I could hard code the name and do
Score2.Focus(Windows.UI.Xaml.FocusState.Keyboard);
but I've got 20 TextBox controls on the page page and I'd like to use the same EventHandler for all of them.
While it may be possible (iterate through the page's control inspecting their tab order and selecting the appopriate next control), I would recommend against it. It will irritate your user if they leave a text box to go back and correct a previous field but your app decides it knows better and gives focus to another field.

Categories

Resources