private void CbComanda_SelectedIndexChanged(object sender, EventArgs e) { comandaCorrente = cbComanda.SelectedValue as Comanda; if (comandaCorrente != null) { txtItens.Clear(); txtItens.Visible = true; btnFecharComanda.Visible = true; string formatoCabecalho = "{0,-6} | {1,-50} | {2,11} | {3,7}\n"; string formato = "{0,6:0} | {1,-50} | {2,11:#.00} | {3,7:#.00}\n"; string cabecalho = string.Format(formatoCabecalho, "Código", "Descrição", "Quantidade", "Preço"); txtItens.AppendText(cabecalho); for (int i = 0; i < 83; i++) { txtItens.AppendText("-"); } txtItens.AppendText("\n"); foreach (ItemComanda item in comandaCorrente.Itens) { string s = string.Format(formato, item.Produto.Codigo, item.Produto.Descricao, item.Quantidade, item.CalcularPreco()); txtItens.AppendText(s); } lbTotal.Text = string.Format("Total: R$ {0,7:0.00}", comandaCorrente.CalcularValorTotal()); } }