---
title: "datagirdview 添加行号"
author: "kkxl"
date: "2011-03-21T21:48:35Z"
tags: []
categories: ["编程语言"]
slug: "datagirdview"
draft: false
lastmod: "2011-03-21T21:48:35Z"
id: 969934
url: "https://kkxl.iteye.com/blog/969934"
---

private void dgvShowData_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
        {
            SolidBrush b = new SolidBrush(this.dgvShowData.RowHeadersDefaultCellStyle.ForeColor);
            e.Graphics.DrawString((e.RowIndex + 1).ToString(System.Globalization.CultureInfo.CurrentUICulture), this.dgvShowData.DefaultCellStyle.Font, b, e.RowBounds.Location.X + 20, e.RowBounds.Location.Y + 4);

        }