Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I've a textbox for input (numeric value) of 12 digits and on the basis of that number I add some data into datagrid. For the first time when I enter any number it works correctly, but after adding data to datagrid when I enter any new number to textbox, it only gets 11 digits. when I check it in debugging mode, I find textbox having 12 digits including "\r" at the start. I don't know from where its come and creates problem.

Any kind of help will be appreciated. Thanks

C#
GroupedManifest grpManifest = new GroupedManifest();
grpManifest.manifestNumber = txtManifestNumber.Text; // get number from textbox
LayoutManifest.DataContext = grpManifest; // set relevant data to layout
manifestList.Add(LayoutManifest.DataContext as GroupedManifest); // add data to list
dataGridGroupedManifest.ItemsSource = null;
dataGridGroupedManifest.ItemsSource = manifestList; // set data to itemsource of datagrid

txtManifestNumber.Text = string.Empty;           // emtpy textbox
txtManifestNumber.Focus();// set focus on textbox


first time this code works excellent but for the 2nd number txtManifestNumber only takes 11 digits (e.g 12345678912) and txtManifestNumber.Text has "\r12345678912" that creates issue on adding data to datagrid
Posted
Updated 11-Sep-13 2:50am
v4
Comments
ZurdoDev 11-Sep-13 8:39am    
We can't know either unless you post your relevant code. Use the improve question link.
Naila Akbar 11-Sep-13 8:51am    
improved
TryAndSucceed 11-Sep-13 11:10am    
I think you should clear the text before assigning it an empty string.
Naila Akbar 12-Sep-13 1:54am    
i have tried this one too but it does not solve my problem. situation is still same.

1 solution

Solution that I got to solve out my problem is..

I catch textInputStart event and there I check that if textbox.text contains "\r" then make it empty and after that I assign it new input. Still I don't get the reason that why there remains "\r" when am assigning it string.empty but my problem is solved in this way.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900