private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.RowIndex >= 0 && e.ColumnIndex >= 0 && e.Value.ToString() != string.Empty)
{
//if (!string.IsNullOrEmpty(this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString()) && this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null)
//{
#region
int UpRows = 0;//上面相同的行数
int DownRows = 0;//下面相同的行数
int count = 0;//总行数
int cellwidth = e.CellBounds.Width;//列宽
//获取下面的行数
for (int i = e.RowIndex; i < this.dataGridView1.Rows.Count; i++)
{
if (this.dataGridView1.Rows[i].Cells[e.ColumnIndex].Value