I have the following problem: I am trying to show the names stored in a list in a MessageBox but the names come out on top of it and not in the center where I want them to be. I attach a photo.
As you can see, the Salmon Salmon names that are inserted by the user in the textbox "name" above and then passed to the DataGridView below when the "add product" button is clicked on the top of the MessageBox and not in the center as I want.
Here is the code:
// CALCULA EL VALOR TOTAL DE LA MESA E IMPRIME EL TICKET
private void btnTicket_Click(object sender, EventArgs e)
{
for (int i = 0; i < Pagos.Rows.Count; i++)
{
total += double.Parse(Pagos.Rows[i].Cells["celdaSubtotal"].Value.ToString());
}
etiquetaTotalNum.Text = total.ToString();
total = 0;
var lista = new List<string>();
string nombre = "";
string mesa = this.numMesa.Trim();
var consultaProductos = "Select nombre from Productos where mesa = @mesa";
using (var comd = new SQLiteCommand(consultaProductos, conexion)
{
Parameters =
{
new SQLiteParameter("@mesa", mesa)
}
})
{
using (var read = comd.ExecuteReader())
{
while (read.Read())
{
lista.Add(read.GetString(read.GetOrdinal("nombre")));
}
}
}
foreach (String nombresProducto in lista)
{
nombre += nombresProducto + Environment.NewLine;
}
MessageBox.Show("Nombre de Producto: ", nombre);
}