title: using datagridview values in a string for printing
body: <p>I created a POS system, in the sales form, user adds products to datagridview and then it gets saved to the database.</p>
  
  <p>I'm currently making the save button print the receipt as well, but I want to add this datagridview items to the receipt but apparently I did it wrong</p>
  
  <p>that's the printing strings</p>
  
  <pre><code>string welcome = "Thank You For Visiting Dulabk";
  string InvoiceNo = txtInvoiceNo.Text;
  string InvoiceDate = dateTimePicker1.Value.ToLongDateString();
  string list = dataGridView1.Rows[i].Cells[1].Value, dataGridView1.Rows[i].Cells[3].Value, dataGridView1.Rows[i].Cells[0].Value;
  
  Bitmap bitm = new Bitmap(list.Length * 30, 90);
  
              using (Graphics graphic = Graphics.FromImage(bitm))
  </code></pre>
  
  <p>so probably the datagridview values should be written different I presume</p>
  
  <p>I use a for statement for the database input</p>
  
  <pre><code>for (int i = 0; i&lt;dataGridView1.Rows.Count; i++ )
          {
              OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=TS-POS.accdb");
              OleDbCommand cmd = new OleDbCommand("INSERT INTO Sales (InvoiceNo,InvoiceDate, Pname, Pprice, Bcode, Staff) VALUES ('" + txtInvoiceNo.Text + "','" + dateTimePicker1.Value + "', '" + dataGridView1.Rows[i].Cells[1].Value + "', '" + dataGridView1.Rows[i].Cells[3].Value + "', '" + dataGridView1.Rows[i].Cells[0].Value + "', '" + lblUser.Text + "')", conn);
             // cmd.Parameters.AddWithValue("@staff", OleDbType.VarChar).Value = lblUser.Text;
              conn.Open();
              cmd.ExecuteNonQuery(); 
              conn.Close();
  
          }
  </code></pre>
  
  <p>Ok Last Update, now printing all information but have problem with all printing in the same line in the code below  I tried using pointf but didn't help</p>
  
  <pre><code> private void printready()
          {
  
  
              stri
  
  ng welcome = "Thank You For Visiting Dulabk";
              string InvoiceNo = txtInvoiceNo.Text;
              string InvoiceDate = dateTimePicker1.Value.ToLongDateString();
              Bitmap bitm = new Bitmap(welcome.Length * 30, 90);
  
              using (Graphics graphic = Graphics.FromImage(bitm))
              {
  
  
                  Font newfont = new Font("Arial Black", 8);
                  Font newfont2 = new Font("Arial Black", 10);
                  PointF point = new PointF(40f, 2f);
                  SolidBrush black = new SolidBrush(Color.Black);
                  SolidBrush white = new SolidBrush(Color.White);
                  graphic.FillRectangle(white, 0, 0, bitm.Width, bitm.Height);
                  graphic.DrawString("" + InvoiceNo + "", newfont2, black, point);
                  PointF pointPrice = new PointF(15f, 45f);
                  graphic.DrawString("" + InvoiceDate + "", newfont2, black, pointPrice);
                  PointF pointPname = new PointF(10f, 65f); 
                  PointF pointBar = new PointF(10f, 65f);
              graphic.DrawString("" + welcome + "", newfont2, black, pointBar);
              PointF pointList = new PointF(10f, 65f); 
  
                  for (int i = 0; i &lt; dataGridView1.Rows.Count; i++)
                  {
  
                      graphic.DrawString("  " + dataGridView1.Rows[i].Cells[0].Value +"" + dataGridView1.Rows[i].Cells[1].Value +"" + dataGridView1.Rows[i].Cells[2].Value +"" , new Font("Arial Bold", 11),
                               new SolidBrush(Color.Black), pointList);
                                      }
  
                  PointF pointItemEnd = new PointF(10f, 65f);
                  graphic.DrawString(" ---------- ", newfont2, black, pointItemEnd);
  
              }
  
  
              using (MemoryStream Mmst = new MemoryStream())
              {
  
  
                  bitm.Save("ms", ImageFormat.Jpeg);
                  pictureBox1.Image = bitm;
                  pictureBox1.Width = bitm.Width;
                  pictureBox1.Height = bitm.Height;
  
  
              }  
  </code></pre>