Results 1 to 7 of 7

Thread: DataGridView Cell Formatting Issue

Threaded View

  1. #1

    Thread Starter
    Lively Member VisualBrian's Avatar
    Join Date
    Nov 2019
    Location
    North America
    Posts
    72

    Question DataGridView Cell Formatting Issue

    I'm using the following code to number the DGV rows in the Row HeaderCell...
    Code:
        Private Sub DataGridViewTable_CellFormatting(sender As Object, e As DataGridViewCellFormattingEventArgs) Handles DataGridViewTable.CellFormatting
            DataGridViewTable.Rows(e.RowIndex).HeaderCell.Value = CStr(e.RowIndex + 1)
        End Sub
    and it works, but the row header blinks like it's constantly cycling through the numbers and the app is sluggish.

    What am I doing wrong?

    EDIT...

    Changed up the code a bit, removed it from CellFormatting and call it whenever the rowcount changes. All is well.
    Code:
    For rowNum As Integer = 0 To .Rows.Count - 1
        DataGridViewTable.Rows(rowNum).HeaderCell.Value = (rowNum + 1).ToString
    Next
    Still not sure why so if anyone knows please enlighten me.
    Last edited by VisualBrian; Jan 28th, 2022 at 08:14 PM. Reason: Solution found
    I may not know anything, but I know it well!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width