A price is being displayed in a RichTextBox
. It takes a double
value representing the price and displays it as a string.
double priceDisplayed = 0.00;
richTextBox_itemPrice.Text = priceDisplayed.ToString("C", new CultureInfo("en-AU"));
The above code results in the price being displayed with the currency on the RHS:
0.00$
Why is this? Checking similar examples, it seems the code above should show the currency symbol on the LHS.
This is really strange, as mentioned in the comment, there must be some culture-clashes on your machine.
In the meantime, you could try something like this on the event TextChanged
:
private void richTextBox_itemPrice_TextChanged(object sender, EventArgs e)
{
string text = richTextBox_itemPrice.Text;
if (richTextBox_itemPrice.Text.Contains("$"))
{
text = text.Replace("$","");
}
richTextBox_itemPrice.Text = "$" + text;
}
And initialize the field to have richTextBox_itemPrice.Text = "$";