|
-
Jan 28th, 2022, 07:30 PM
#1
Thread Starter
Lively Member
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!
-
Jan 28th, 2022, 08:07 PM
#2
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.
-
Jan 28th, 2022, 08:19 PM
#3
Thread Starter
Lively Member
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.
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.
I may not know anything, but I know it well!
-
Jan 28th, 2022, 08:31 PM
#4
Re: DataGridView Cell Formatting Issue
 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.
 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.
-
Jan 28th, 2022, 09:02 PM
#5
Thread Starter
Lively Member
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.
I may not know anything, but I know it well!
-
Jan 29th, 2022, 04:31 AM
#6
Re: DataGridView Cell Formatting Issue
 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.
-
Jan 29th, 2022, 11:41 AM
#7
Re: DataGridView Cell Formatting Issue
 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
to hunt a species to extinction is not logical !
since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|