How to show names of a list in a MessageBox?

0

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);



    }
    
asked by Nacho Zve De La Torre 28.06.2018 в 04:08
source

1 answer

1

Try putting the texts upside down

MessageBox.Show(nombre, "Nombre de Producto: ");

I recommend using this message to make the message more attractive:

MessageBox.Show(nombre, "Nombre de Producto: ", MessageBoxButtons.OK, MessageBoxIcon.Information);

Here is the MessageBox documentation

I hope it serves you.

    
answered by 28.06.2018 / 04:24
source