Format the ComboBox value pulled from the SQL database (LINQ) in C# Project (WPF)

Question:

I need some help in the code below…I need to make the Float value pulled from the SQL Bank to be in the Brazilian Real Number Set format in a C# (WPF) project in a ComboBox (as Double). That is, bring it as a String in IntemsSource and not be in this "0.000" format, but in this "0.000".

Code:

var query_Fardo = from f in oDB.tabProdutos 
                  where f.Codigo == Convert.ToInt32(txtCodigoApontaPrd.Text) 
                  select f.Fardo;
CmBox_FardoApontaPrd.ItemsSource = query_Fardo;
CmBox_FardoApontaPrd.ItemStringFormat = "0,000";//Não funciona

Grateful for the support…

Answer:

I didn't quite understand if I wanted the type to be Double , but here's an answer transforming it to string :

var query_Fardo = from f in oDB.tabProdutos 
                  where f.Codigo == Convert.ToInt32(txtCodigoApontaPrd.Text) 
                  select f.Fardo.ToString("#,###.###");

With that, it would not be necessary

CmBox_FardoApontaPrd.ItemStringFormat = "0.000";

Scroll to Top