Hey everyone,
I'm trying to display the Price and Cost values as currencies but I did not get it right. Take a look at my code and tell me what I'm doing wrong please:
Code in my StockHelper class:
public string DisplayPrice(decimal price)
{
string temp = string.Format("{0:C}", price);
return temp;
}
Code in AdminForm_Load event handler:
string priceValue = ProductsDGV.Columns["Price"].ToString();
priceValue = StockHelper.DisplayPrice(Convert.ToDecimal(priceValue));
Any suggestions?
EDIT: I've just used the same method to display the price of the product in my invoice form and it worked just fine. I guess the problem is not in the method itself, it's in the way I'm trying to display the values of the Price column of the DataGridView.
Here's the code I've used in the invoice form:
string productName = (string)ProductsCB.Items[(int)ProductsCB.SelectedIndex];
double price = HarbDB.Products.Single(p => p.Name == productName).Price;
PriceTB.Text = StockHelper.DisplayPrice(Convert.ToDecimal(price));