15.2. 让DataGridView显示行号:dgvDrawHeaderNum


    //draw the row index
    public void dgvDrawHeaderNum(DataGridView dgvValue)
    {
        for (int index = 0; (index <= (dgvValue.Rows.Count - 1)); index++)
        {
            int number = index + 1;
            dgvValue.Rows[index].HeaderCell.Value = String.Format("{0}", number);
        }
    }

    

例 15.2. dgvDrawHeaderNum 的使用范例


dgvDrawHeaderNum(dgvSearchedAlerts);