1 Attachment(s)
[RESOLVED] DGV Column header
I coded the following to have a DGV Column header appear as specified.
Code:
.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
.ColumnHeadersDefaultCellStyle.Font = New Font("Times New Roman", 11, FontStyle.Bold)
.ColumnHeadersDefaultCellStyle.ForeColor = Color.Red
.ColumnHeadersDefaultCellStyle.BackColor = Color.LightSteelBlue
What I got was this:
Attachment 154325
So I have apparently done this wrong, but I am at a loss as to why the color and backcolor failed to execute.
Re: [RESOLVED] DGV Column header
True story: quoting and linking to the documentation is the professional move. Everything else was there to make JMC feel smarter than you.
DGV is a complex control with literally hundreds of properties. You should take the time to read as many of the documentation pages as you can. It's not everyone's idea of fun. But 90% of what I learned in early VB was literally just reading random MSDN pages and trying the examples. You can't learn what's there if you don't look! The hard part is "Ugh I need to know how a feature works but I'm not sure it exists". The best way to make that easy is to read about as many features as possible, even the ones you don't need right now, so it becomes, "Ugh dang I remember this was a feature but I forget which dang properties it was."
You really do need to devote the time to it, though. An entire book could be written JUST about this one control, it's huge.
Re: [RESOLVED] DGV Column header
I admit that up until recently I did a lot less of that than I do now. The reason is that much of the material is just not comprehensible unless the person reviewing the material has a base of knowledge that enables understanding. Additionally, my own personal knowledge base is such that frequently I was unable to search any of the reference material and return anything that was even remotely related to what I was wanting to know.
It has only been in the last few months that I can consult much of the knowledge base, etc. information and even come close to knowing what is being discussed and how it might be applied to my own situation. Kind of like, years ago, when I learned calculus and was able to do things with electronics that had previously just been words with no meaning to me. And as I stated before, when one is searching through any kind of reference material, the first requirement is that there be enough base knowledge such that the search parameters will yield information that actually relates to the task at hand.
I am learning though and am now finding more and more of the answers to my question on my own. I am trying Sitten, but it is a long slow process.
Re: [RESOLVED] DGV Column header
Quote:
Originally Posted by
Sitten Spynne
True story: quoting and linking to the documentation is the professional move. Everything else was there to make JMC feel smarter than you.
Teach a man to fish... etc. Slap him with the fish you caught while teaching him how to fish and you may not make a friend but it's not a lesson that will soon be forgotten. I'll say again, I find it rather amusing that I'm the one assuming that others are capable of doing as I do and yet I'm supposedly the one who thinks that I'm superior.
Quote:
Originally Posted by
Sitten Spynne
The hard part is "Ugh I need to know how a feature works but I'm not sure it exists".
That can be the case at times but, if you're using a particular type or member in your own code, you know that type or member exists. Reading the documentation for that type or member is a pretty good place to start.
Quote:
Originally Posted by
gwboolean
All snide aside, I did indeed peruse the Help system and was unable to find the information that would provide the answer for this issue. Probably due to the fact that I had no prior knowledge of many of the capabilities residing in VB.
As I said, you were using the ColumnHeadersDefaultCellStyle property in your code so that would have been a likely place to look. Maybe not the first, as you are using other properties too, but certainly A place to look.
Quote:
Originally Posted by
gwboolean
It is a crap shoot and I am sure that even professionals such as yourself are not always able to find the information that fits the situation you are in.
To say that it's a crap shoot - or even a craps shoot ;) - is significantly overstating the case. It obviously depends on what the actual problem is as to whether you can find the solution in the documentation. I certainly don't claim that you will always find what you need or understand everything you find. Clearly though, what you look for is a big factor in how often you will. Hopefully, whatever else is taken from this thread, you will have a better idea of how to use the Help effectively in future. If you've learned something and your already low opinion of me hasn't been tarnished then I call that a win. :)
Re: [RESOLVED] DGV Column header
Quote:
Originally Posted by
gwboolean
I admit that up until recently I did a lot less of that than I do now. The reason is that much of the material is just not comprehensible unless the person reviewing the material has a base of knowledge that enables understanding. Additionally, my own personal knowledge base is such that frequently I was unable to search any of the reference material and return anything that was even remotely related to what I was wanting to know.
It has only been in the last few months that I can consult much of the knowledge base, etc. information and even come close to knowing what is being discussed and how it might be applied to my own situation. Kind of like, years ago, when I learned calculus and was able to do things with electronics that had previously just been words with no meaning to me. And as I stated before, when one is searching through any kind of reference material, the first requirement is that there be enough base knowledge such that the search parameters will yield information that actually relates to the task at hand.
I am learning though and am now finding more and more of the answers to my question on my own. I am trying Sitten, but it is a long slow process.
I think that a big problem is that people tend to search for a question or a clause rather than looking for specific pages on specific types or properties. No doubt experience increases the amount of information that is meaningful but, in this case, going directly to the page for a specific property that you were already using mentioned the exact issue. I'm confident that:
Quote:
If [...] EnableHeadersVisualStyles is set to true, [...] the ColumnHeadersDefaultCellStyle values are ignored.
is something that you don't need too much experience to understand. Maybe I'm wrong about that. I don't think so, but who ever does think that they're wrong without it being demonstrated so? Anyway, the point is that being specific is often a very good idea. If you're using a specific type or member then reading the documentation for that type or member is never a bad idea.
Re: [RESOLVED] DGV Column header
Quote:
Originally Posted by
jmcilhinney
Teach a man to fish... etc. Slap him with the fish you caught while teaching him how to fish and you may not make a friend but it's not a lesson that will soon be forgotten. I'll say again, I find it rather amusing that I'm the one assuming that others are capable of doing as I do and yet I'm supposedly the one who thinks that I'm superior.
That can be the case at times but, if you're using a particular type or member in your own code, you know that type or member exists. Reading the documentation for that type or member is a pretty good place to start.
As I said, you were using the ColumnHeadersDefaultCellStyle property in your code so that would have been a likely place to look. Maybe not the first, as you are using other properties too, but certainly A place to look.
To say that it's a crap shoot - or even a craps shoot ;) - is significantly overstating the case. It obviously depends on what the actual problem is as to whether you can find the solution in the documentation. I certainly don't claim that you will always find what you need or understand everything you find. Clearly though, what you look for is a big factor in how often you will. Hopefully, whatever else is taken from this thread, you will have a better idea of how to use the Help effectively in future. If you've learned something and your already low opinion of me hasn't been tarnished then I call that a win. :)
"Teaching a man to fish", in my book, involves some education about lures, fish behavior, and ultimately providing practical lessons about how to hold the rod, casting, reeling in, etc. I like my student/teacher relationship to be something friendly and rewarding.
As constructively as I can put it, your style of teaching is, "Here's the book. I'm going to read it to you because clearly you're too lazy." Sometimes you provide the practical lessons. Other times you seem to leave it at "the book has illustrations and I showed it to you, jeez do something on your own for once." This is a "tough love" approach. In literature this usually ends with the student becoming the master via a fight to the death. Very rarely are the people who practice it portrayed as admirable.
The best parts of your post are where, instead of reading the book to the student, you teach practical lessons. Shoot for this:
Quote:
You can read about this feature at [ <list of MSDN links> ], but here's the short version:
If property A is set, it means property B won't be set. (See <source>.) So if you really need to use property B, you shouldn't set property A. There are many other related properties like that, consider spending an hour or two reading the articles I linked!
That doesn't come off as patronizing, and still has an awful lot of "read the documentation" in it. You've made quite a few posts like this lately, and when people get upset over them I've been trying to scold them because you've got a volume of knowledge on TableAdapters and DataGridView that'd take me too long to acquire myself and I usually learn something from those answers.
But when I have to wade through you writing a whole paragraph to say "I think you were too lazy to read the docs" I tend to skip it. It doesn't feel like there'll be anything useful in those posts. You're burying your best content underneath bile and trash.
Be Mr. Miyagi. Not Ra's al Ghul. They were both teachers who produced excellent students. Only one of them was a respectable man.
Re: [RESOLVED] DGV Column header
i need to butt in here again since i recently quiet often felt the wrath of jmcilhinney :D....
I personally totally agree with your methods to an extent too, if you look at alot of my posts i don't do much coding in replies but i always give some sort of direction and advice at how exactly i might approach something.... (in fact just like you do Jm, but without the snarls behind it <3 as Sitten seemed to point out too and the OP).
But i take my hat off to you and everyone here for many years you all have helped me tremendously and your skills are very clear.....so dont stop helping me :D.....
As for the OP, did you manage to find out what your problem was? i dont seem to see if you got it or how you got it fixed.
Re: [RESOLVED] DGV Column header
Quote:
True story: quoting and linking to the documentation is the professional move. Everything else was there to make JMC feel smarter than you.
You must have forgotten that JMC offers the option of ignoring his posts, thus negating the impending circlejerk