0

I want to show the currency format for the tow labels like this "150,000,000"

this is my code

cn.Open();
            cm = new SqlCommand("SELECT SUM(price*qty),SUM(buy_price*qty) FROM tblproduct", cn);
            dr = cm.ExecuteReader();
            while (dr.Read())
            {

                lblTprice.Text = dr[0].ToString();
                lblTbuyPrice.Text = dr[1].ToString();
                

            }
            dr.Close();
            cn.Close();
  • [The "," custom specifier](https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-numeric-format-strings?WT.mc_id=DT-MVP-5003235#the--custom-specifier-2) – Reza Aghaei Jan 30 '21 at 14:31
  • [The Currency ("C") Format Specifier](https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings?WT.mc_id=DT-MVP-5003235#the-currency-c-format-specifier) – Reza Aghaei Jan 30 '21 at 14:32
  • Actually, if you wanna add a thousand separator for label text you can check this page out. [https://stackoverflow.com/questions/65625258/how-to-add-a-thousand-separator-for-a-textbox-in-winforms-c-sharp/65625259#65625259] – Alireza Mahzad Jan 30 '21 at 16:51
  • Please see [C# Data Connections Best Practice?](https://stackoverflow.com/questions/17552829/c-sharp-data-connections-best-practice) – Charlieface Jan 30 '21 at 22:02

1 Answers1

0
lblTprice.Text = dr[0].ToString("C", CultureInfo.CurrentCulture);
lblTbuyPrice.Text = dr[1].ToString("C", CultureInfo.CurrentCulture);
Bhuban Shrestha
  • 1,304
  • 11
  • 27