Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hi all,



I have a strange problem with the Combobox.RightToLeft property in Windows Vista and Windows 7.

I have a combobox that is for inputting a price (i.e. 7.99) - this I have set to RightToLeft for various reasons, but it's what is needed in this instance.

Problem is that when you type in '7.99', when you type '.', the point jumps to the beginning of the text (so it displays '.7'), however if you then type the next number, it jumps back to where it should be (so now displays '7.9').

Testing shows that this isn't just the decimal point, but to most non-alphanumeric characters such as exclaimation marks and slashes.

Has anyone else come across this, and know of a way to fix it? It's in .NET 3.5 incidentally, I'm thinking of testing it out in .NET 4 to see if it does the same.

Ultimately, the comboboxes still function correctly, but it's irritating and can be quite confusing to a user.

Kind Regards.
Martin Davies.

[Original Question Title = Combobox RightToLeft property moving characters around Win Vista/7...]
Posted
Updated 8-Dec-10 0:44am
v2
Comments
Slacker007 8-Dec-10 6:45am    
Updated Question title - too long. Added tags.
Kschuler 8-Dec-10 12:19pm    
Do you have any events for the Combobox that could be interferring?
Martin P. Davies 8-Dec-10 12:22pm    
Hi Kschuler, no, definitely not - it's a .NET problem - I created a brand new project to test, nothing in it at all, apart from a single Combobox with RightToLeft set to true, and it behaved in exactly the same way...
Manoj from Pune 9-Dec-10 1:47am    
Martin,
Right to Left property is used to assign values in control in Right to Left fashion for RTL languages such as arabic.. So when you write any text in control with right to left property set, the last value comes to the first position considering it is a text, but when you write a number or decimal number it is universally written as Left to Right.. So when u type 7 then "." that dot is still consodered in string so it goes in first position and then when you type 9 ie "7.9" it is clearly a decimal number so the "dot" comes back to where it needs to.
Its not at all a .NET problem.

1 solution

Martin, Right to Left property is used to assign values in control in Right to Left fashion for RTL languages such as arabic.. So when you write any text in control with right to left property set, the last value comes to the first position considering it is a text, but when you write a number or decimal number it is universally written as Left to Right.. So when u type 7 then "." that dot is still consodered in string so it goes in first position and then when you type 9 ie "7.9" it is clearly a decimal number so the "dot" comes back to where it needs to.
Its not at all a .NET problem.
 
Share this answer
 
Comments
Martin P. Davies 9-Dec-10 4:29am    
Thanks for that Manoj, that's useful information. My only question before I accept the answer is that why does it not behave like this in Windows XP?

Plus, the other thing I don't understand is why if you type a string (e.g. 'hello'), why does it appear 'hello' and not 'olleh'? Is that due to language settings rather than the right to left property?

I suppose what I need to know also is a way to right-align text in a combobox without using the RightToLeft property...
Martin P. Davies 9-Dec-10 4:41am    
It's also not just decimal numbers when it does this. If you type 'yo', it appears 'yo', but it you type a dot it then appears '.yo', then type a u it appears 'yo.u'. I understand what you are saying about the numbers, but I don't understand why it would work like this in text too. I'm probably missing something I admit, but if anyone can clarify it would put my mind at rest!

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