Click here to Skip to main content
15,912,400 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using a label to display the current amount entered in my application..

So basically there is a keypad that goes from 1-9 including 0 and 00.

I want the label to display 00.00 at all times until a number is entered.

So if i wanted to enter the price £12. Then i would enter 1200 on the keypad and it would come up as 12.00 in the label. So its bascically moving from right to left each time a number is entered.

Someone recommended label.Content = "00.00", but that doesnt work because the minute i press 1 on the keypad then it displays "00.001"..

So basically i want the numbers entered to replace the 00.00 that are already there.
Posted

By using the keypad and label you are trying to mimic some historical equipment like a cash machine, or something like that. Don't do it. I can only confuse the users and drive them mad. The popular idea of mocking old bad machines using modern computer is counter productive. All data should be presented in a natural way and exactly in the place it its typed in, nowhere else. There should not be a label and, especially, no keypad.

Use, for example, this control: https://wpftoolkit.codeplex.com/wikipage?title=MaskedTextBox[^].

—SA
 
Share this answer
 
Comments
[no name] 7-Mar-15 23:50pm    
The problem with my application is that it is an EPOS system, so it needs the numberpad for the users to enter in the price via touchscreen.
However, your comment has revealed MaskedLabels to me which i shall read up on in attempt to solve my problem. Thank you
Sergey Alexandrovich Kryukov 8-Mar-15 0:15am    
Excuse me, is that the only entering method? Then sorry for misunderstanding, it of course should be there, but it should behave like a regular keyboard entering data in a text box. Not in a label. Label should be something static. Don't confuse the users.
—SA
[no name] 8-Mar-15 0:45am    
Yes, it is the only entering method. But I agree, after looking online, displaying the amountEntered in a label is a bad idea. But it seems I have to find MaskedTextboxes that allow for the masking of £00.00
Sergey Alexandrovich Kryukov 8-Mar-15 0:46am    
Honestly, this is not a bad idea...
—SA
[no name] 8-Mar-15 18:13pm    
Sergey, You will be proud to know I have managed to figure this out. I knew that it was something oh so simple, I just couldn't figure out what it was.. When we was talking about MaskedTextboxes and MaskedLabels, The answer was simply:

amountOutputLabel.Content = string.Format("£{0}", Math.Round(Amount / 100, 2));
A fellow programmer had provided me with the answer which was indeed two lines of code as oppose to the 20+ lines of commented out code that i had tried and failed with.

I just had to times the number by 10 then at the button number then divide it by 100 again.
 
Share this answer
 
Comments
macika123 8-Mar-15 19:56pm    
Hello, I have read your whole question with answers, but I still have one tiny question - I'm just curious no offense intended :) :
Why should the cashier type double zeros for each round price tag? It seems, that cashier might save a little time and it's less probably that they type 0.12 instead of 12.00. Or do they have all price tags ending in .99 :) ?
[no name] 8-Mar-15 21:55pm    
I don't think I understand your question completely, please correct me if i don't. But there are some products that aren't £12.00 or rounded off to the nearest pound, some examples are 4.60, 4.90, 15.90 but to have the 2 decimal places, it is good for practice and the user can see how much the total is :) I apologize again if i've not replied to your question properly, if i havent please feel free to reply :)
macika123 8-Mar-15 22:37pm    
I thought about the case, when something costs 12.00 pounds. Then the cashier must type 1200, if I'm correct, and that means two "unnecessary" characters. I think that you can easily forget to type these two additional zeros. If there are plenty items, the cashier might not realise the mistake by looking at the total price.
On the other hand, I see, that if you have price tags mostly ending to .90, than both approaches have the same press count e.g. 1.9 = 2 numbers 1 decimal point vs. 190 = three numbers.

The main reason I asked, that I obviously see cash machines, that have product numbers stored in their memory or simply use barcodes. I can remember the cash machines used at grocery stores, where the cashier typed the price, but to be honest I don't recall which method they used.

It's my bad, that my question was confusing, sometimes I struggle to formulate my questions. Thanks for your reply, you already have the solution and I ask details :) .

Little edit: I presumed, that you have to able type prices like 1.95, but it seems, that you don't. In which case I found it more weird, that you display two numbers after decimal point, but you can't change the least significant one. But I understand that this was the best option for you :) .
[no name] 8-Mar-15 23:52pm    
No not your bad at all my friend, see my POS system is for a bar, so the option of scanning barcode isn't present, so the bartender would just the product on the list of buttons. And as a part-time bartender myself, i can say first hand, I have never had to type in the price of a product, the only thing I have typed in is the amount of money the customer has given to me. Which is what the keypad in this question was related to :)

Another comment i will make is that based on what you say about entering the 1200 manually, with this POS system that isn't the case. The each product all has buttons on the system which contains all of the information on that product, this may be Price, Description, Name, Category, even pictures.

So for my system, the person is not typing in the price of each product, they would just find the product amongst the many buttons on the screen and press it, the only number they are typing into the system is the amount of money the customer has given them :)

I hope this has cleared your enquiries up :)

It's crucial that you know that the system I am making is for a bar/club so the user/bartender would just press the button related to each product whereas your correct, for a cashier in a grocery store they would just scan the barcode :)
macika123 9-Mar-15 1:06am    
Now I think I know everything :) . Thanks for your time to clarify me your application. This was a little out of box for me, that's why I commented. Even I checked the Wikipedia article for pound sterling, whether 1/100 pound coins exist :) .
Thanks again ;).

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