I need to show a column in the datagridview column of gross weight this format 0.00, but I'm not getting it, this column is not created in any database, I created the direct column in the datagridview, I already went in the numeric formatting of the column, I left as N2, and even then nothing to format the column. I need when I type a decimal number in the column, EX digit 10 when exiting the cell, need to show 10.00
Follow my code:
private void btn_xml_Click(object sender, EventArgs e)
{
string FileName = @"C:\Xml_Entrada\" + txt_chave.Text + ".xml";
List<ClasseItensXml> ListaItens = new List<ClasseItensXml>(); //A lista é do tipo ClasseItensXml
XmlDocument doc = new XmlDocument();
doc.Load(FileName);
var proditens = doc.GetElementsByTagName("prod");
foreach (XmlElement nodo in proditens)
{
ListaItens.Add(
new ClasseItensXml()
{
CodigoProduto = nodo.GetElementsByTagName("cProd")[0].InnerText.Trim(),
NomeProduto = nodo.GetElementsByTagName("xProd")[0].InnerText.Trim(),
QuantidadeComercializada = nodo.GetElementsByTagName("qCom")[0].InnerText.Trim()
});
//Repare que cada "nodo" é um item, portanto só adiciona um ClasseItensXml na lista.
}
dgw_Xml.DataSource = ListaItens; //por fim, usa a lista de source
dgw_Xml.Columns["PesBruto"].DefaultCellStyle.Format = "N2";
}