I have the following line :
if ( dataGridView1.Rows[i].Cells[0].Value.ToString().Length >= 13 ){
e.Graphics.DrawString
(dataGridView1.Rows[i].Cells[0].Value.ToString().Substring(0,14),
print6B, Brushes.Black, x-10, 130 + height);
}
else {
Because of the Substring method i get this error:
index and length must refer to a location within the string c#
What is the best method to get the first 14 characters of the string ?
It looks fine to me. Are you sure you aren’t grabbing the header row? It’s a common error when dealing with the gridview.
You can see more on the row types here