Header line of a ListView
vieuxray
-
vieuxray -
vieuxray -
Good evening everyone, forum good evening,
<config>Windows 10/ Internet Explorer 11.0</Excel 2007-- VBA>
I have seen during my various research on the internet the possibility of coloring the row and/or the text containing the headers of a ListView. Usually, I save tips and tricks, but I forgot this time.
So, I can no longer find this tip.
I am looking for the code to change the color of the row or the text color, whatever can be done.
Thank you all for your help, soon the end of the year 2018, so happy holidays to everyone.
Best regards, Ray
<config>Windows 10/ Internet Explorer 11.0</Excel 2007-- VBA>
I have seen during my various research on the internet the possibility of coloring the row and/or the text containing the headers of a ListView. Usually, I save tips and tricks, but I forgot this time.
So, I can no longer find this tip.
I am looking for the code to change the color of the row or the text color, whatever can be done.
Thank you all for your help, soon the end of the year 2018, so happy holidays to everyone.
Best regards, Ray
Public Sub Remplissage() Set Feuil1 = ActiveSheet With ListView1 .Gridlines = True .FullRowSelect = True .FlatScrollBar = True .LabelEdit = lvwManual With .ColumnHeaders Clearlist .Add , , " ( I )", 43, lvwColumnLeft .Add , , "( J )", 43, lvwColumnCenter .Add , , "( K )", 43, lvwColumnCenter .Add , , "( L )", 43, lvwColumnCenter .Add , , "( M )", 43, lvwColumnCenter .Add , , "( N )", 43, lvwColumnCenter .Add , , "( O )", 43, lvwColumnCenter End With End With
12 answers
-
Hello,
I found something here: https://www.codeguru.com/vb/controls/vb_listview/article.php/c1673/ListView-Coloured-Headers-Example.htm
But VB5.0, I modified your file
modified file: https://mon-partage.fr/f/7A3zy5QF/ -
Hi f894009,
Thank you very much for the find; the code I had seen was much shorter, but we still need to know if it was really for the headers, I don’t remember very well.
Thank you for modifying the code. I will try to adapt it to my program, but still, I didn’t expect such a long code just for the headers.
I just did a first test, and there are several undeclared variables according to OPTION EXPLICIT. I will try to tidy things up if I can.
In any case, thanks again for this find.
Have a good Sunday.
Best regards, Ray -
Hello f894009,
Thank you for your response,
I modified the code you sent me this morning and it crashed Excel; I must have done something wrong.
So, I deleted the file and I’m going to start over. However, you suggested (No problem, if it's for the other lines, I have what you need, but only the text color), I'm interested, so if you could please integrate all that into the file from this morning, as I would see everything at once.
Given the time, enjoy your meal and have a great Sunday, and thank you.
Best regards, Ray -
Hello f894009,
Thank you for the response,
I have a little issue, I took your file back and did some tests but there is a problem that I couldn't find.
I didn't modify the file, I launch it, open the USF and click on the button that displays the header in red background and white text and
the list is displayed in red but as soon as I click on a line to see what happens, Excel crashes and I have to exit using CTRL shift and enter and then end the task.
You mentioned that the lines of the listview are in red instead of black, instead of what does that mean ???? I didn't understand.
Thank you for your help, have a good day.
Best regards, Ray -
Hello f894009,
Thank you for getting back with the file, unfortunately it doesn't change anything for me, it still crashes as soon as I click the button to display the list in listview1.
There is something it doesn't like right from the start.
I haven't touched anything in the code, I promise hehehe
Enjoy your meal, talk to you later and thanks
Best regards, Ray -
Re f894009,
Thank you for the code modification, it's working much better without Excel crashing.
The rows are coloring nicely, so we could use a different color for each column, which is great, thanks.
However, can I stop changing the color of the header row???
See you later
Best regards, Ray -
-
Hello f894009,
I am sending you my best wishes for this new year.
Thank you for the file return, sorry but I have an issue, I open the file, click on the button, the list displays well, header row in red, text in white.
Then poof Excel crashes, no other solution than the 3 keys to get out CTRL Shift enter and task manager.
Have a great first day of 2019, thank you.
Best regards, Ray-
Re,
Header line in red, white text.
Yes, the color needs to be modified in userform_initialize at the end of the procedure
Then plouf Excel crashes
Yes, but I have no problems here!!!
We should set a breakpoint at the beginning of:Private Sub CommandButton1_Click()
Launch the userform and as soon as the execution stops, press the F8 key to step through the code line by line to see where it crashes.
Question: which file are you using??
-
-
Re,
for the file, I'm using the one you sent me this morning
I don't tinker with the file until it works, then I make a backup and modify it, I look at how it works
and adapt it to my source file.
I've followed your advice:
I should set a breakpoint at the beginning of: Private Sub CommandButton1_Click()
Run the userform and as soon as execution stops, press the F8 key to step through the code line by line to see where it fails.
As soon as I click F8, it fails there, and I no longer have access to the faulty code.
Have a good day
Best regards, Ray-
Re,
Well!!! I can't see what it could be!!
However, there's something that doesn't add up; you wrote that the list displays and then crashes, and now you're saying it crashes on the second line of the button code!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Since it doesn't crash without the header color, take back the file without the header color….. -
Re,
I've tried all the versions and it's not working.
So I open the file, I click on the button, the list displays fine, header in red, text white.
I maintain that this is what I do every time, I click on the button, the list appears fine and then nothing afterwards.
With the colored list it works
with the header it doesn't work, I crash
with both together, I crash
The purpose of my post was to have the ability to change the color of the header, it's glitching
Given the complexity of the code, we might need to check the compatibility with Excel 2007 on Windows 10
I still think it's the display of the header that's causing us trouble, but that's just my opinion.
Thank you for your help
Best regards, Ray -
-
-
Re
Your last line tells me:
Since it doesn't crash without the header color, take the file without header color…
Okay, but that's not in line with my request. What I want is to be able to modify the header color. Your discovery was fine, but unfortunately it bugs out.
Have a good evening. -
Hello f894009,
Thank you for your response, so I'll drop it, it's not a big deal or essential.
Wishing you all the best and thanks again for your help.
Have a good day.
Best regards, Raymond -
Hello f894009,
I switched to fiber, and it seems to be working fine.
Well, I tried to place a Label in the foreground on Listview1
but I'm having an issue and can't seem to do it.
It's as if the bring to front and send to back commands are disabled.
I've already done plenty of drawings using bring to front and send to back without any problems, so I don't understand why it's not working anymore.
Everything on my PC is functioning well, just like before changing providers, not even an error.
Otherwise, it should be fine for the Label.
Thanks to you, and have a nice evening.
Best regards, Ray