- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
private void DBGridCategories_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
        {
            int rowsCount = (sender as DataGridView).RowCount;
            if ((rowsCount >= 0) && (rowsCount < 100))
            {
                (sender as DataGridView).RowHeadersWidth = 30;
            }
            else
            {
                if ((rowsCount >= 100) && (rowsCount < 1000))
                {
                    (sender as DataGridView).RowHeadersWidth = 40;
                }
                else
                {
                    if ((rowsCount >= 1000) && (rowsCount < 10000))
                    {
                        (sender as DataGridView).RowHeadersWidth = 50;
                    }
                    else
                    {
                        if ((rowsCount >= 10000) && (rowsCount < 100000))
                        {
                            (sender as DataGridView).RowHeadersWidth = 65;
                        }
                    }
                }
            }
            using (SolidBrush brush = new SolidBrush(Color.Red))
            {
                e.Graphics.DrawString((e.RowIndex + 1).ToString(System.Globalization.CultureInfo.CurrentUICulture) + ".", e.InheritedRowStyle.Font, brush, e.RowBounds.Location.X + 10, e.RowBounds.Location.Y + 1);
            }
        }
                                 
        
А почему аффтар не рассмотрел вариант rowsCount >= 100000 ?