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.
Re: DataGridView Cell Formatting Issue
Why would you be changing the Value of a cell on an event that exists for formatting? That's what you're doing wrong.
Re: DataGridView Cell Formatting Issue
Quote:
Why would you be changing the Value of a cell on an event that exists for formatting? That's what you're doing wrong.
You have a very annoying habit of answering a question with a question. Thanks for pointing out my error but explaining why it's wrong would have been much more helpful. To me, anyway. As your response was (and almost always is) for your own benefit, I'm happy to make you feel superior once again. You're welcome.
Anyway, I thought I asked you to stop responding to my questions.
Re: DataGridView Cell Formatting Issue
Quote:
Originally Posted by
VisualBrian
You have a very annoying habit of answering a question with a question.
That's because I want to prompt people to think for themselves as much as possible. The questions I ask are the sorts of question you should be asking yourself.
Quote:
Originally Posted by
VisualBrian
I thought I asked you to stop responding to my questions.
I'll respond to questions as and when I see fit. You're completely within your rights to ignore any responses you don't like, given that protecting your ego seems more important than learning.
Re: DataGridView Cell Formatting Issue
You are not my teacher or my daddy. I am not a child or a student. This is not my profession. I am not here for help with my homework. I am a retired Army Veteran and Air Traffic Controller who now stays home and codes for fun. I come here to get help when I get stuck.
If someone came to me with a question about Air Traffic Control procedures, I would be happy to teach them whatever they wanted to know. I would not call them lazy, or tell them to go look it up, or try to make them feel small. I treat people with respect and expect the same in return.
In reading many of the posts in which you have responded, I was hard pressed to find one where you actually helped someone. If I must come here again, I hope you'll try to not post to me unless you actually want to help. I think that's a reasonable request, but as you said, you can do whatever you like.
Re: DataGridView Cell Formatting Issue
Quote:
Originally Posted by
VisualBrian
In reading many of the posts in which you have responded, I was hard pressed to find one where you actually helped someone.
You're obviously right. In 17 years and over 100,000 posts, I've never helped anyone. I have to confess, I hacked the system and added over 11,000 reputation points myself. I knew someone would find me out eventually. Good job.
Re: DataGridView Cell Formatting Issue
Quote:
Originally Posted by
jmcilhinney
You're obviously right. In 17 years and over 100,000 posts, I've never helped anyone. I have to confess, I hacked the system and added over 11,000 reputation points myself. I knew someone would find me out eventually. Good job.
oh you little tasmanian devil https://www.youtube.com/watch?v=tRE52ZUJ0gc