[Closed] colors in a .NET listview
Hi,
I’m having trouble implementing a script across my company. The script uses a .NET listview with two columns and N rows. The first row of cells has no text but just a backgroundcolor. The second row has a name in it and has no color. When i run the same script on different computers some don’t show these colors. The functions work just fine, but the colors don’t show up in the interface. It’s all on max2008 btw. The computers not showing the colors are always the same and don’t have some distinct feature switched on or off as far as i know.
Here’s a piece of the code
(
try(destroyDialog theWhatsMyNameRollout)catch()
global theWhatsMyNameRollout
--the list of names
local nameListArray = #("glas","vloer","rollaag","trasraam","Script by Klaas","wand")
--initialize the listView
function fn_initListview lv =
(
lv.columns.add "" 16 --the color column
lv.columns.add "" 80 --the name column
lv.View = (dotNetClass "System.Windows.Forms.View").Details
lv.HeaderStyle = lv.Headerstyle.none --i don't want to see the columnheader
)
--populate the listview
function fn_populateListview names lv =
(
local theItemArray = #()
for o in names do
(
--the first item is the color
theItem = dotNetObject "listViewItem" ""
theItem.UseItemStyleForSubItems = false--don't use colors of the main item in the subitem
--the subItem hold the actual name
theItem.subItems.add o
----here i'm applying the color. these colors don't display on every computer
theColor = random white black
theItem.backColor = (dotNetClass "System.Drawing.Color").fromARGB theColor.r theColor.g theColor.b
append theItemArray theItem
)
lv.items.addrange theItemArray
)
rollout theWhatsMyNameRollout "whatsmyname"
(
dotNetControl lvNameList "System.Windows.Forms.ListView" width:100 height:100 offset:[-11,0]--pos:[2,35]
--init and populate the list when the rollout opens
on theWhatsMyNameRollout open do
(
theWhatsMyNameRollout.height = (lvNameList.height + 10)
fn_initListview lvNameList
fn_populateListview nameListArray lvNameList
)
)
createDialog theWhatsMyNameRollout 105 10
)
So, is there an option or property in the listview i have to turn on to get consistent results? Or is there a max option which influences the display of these colors? I’ve got no idea why one computer is different than the other (when running this script).
Klaas
no particular idea except this… check if all the machines have the same .NET framework version installed.
Thanks,
i’ve checked on two machines which don’t display the colors. One machine had less .net entries in the applications list of windows, the other one had exactly the same. I’m going to test some more things in the meanwhile.
Klaas
Open up the listview, press Ctrl+Alt+Delete, and cancel, and see if you see the colors. If they are there, you have some sort of driver conflict. As strange as it may sound, check the mouse and keyboard drivers (uninstall them one at a time). If they aren’t there, you have a more serious problem.
Well professor, you do credit to your name.
ctrl+alt+del actually shows the colors. I also managed to get the colors by putting my rollout in a floater instead of using “createDialog”. Although i didn’t want to use a floater in the first place. So i’ll be looking into the solution you mentioned.
What’s up with the drivers? Could you explain what the ctrl+alt+del actually does? I’m very curious. The mouse and keyboard drivers may somehow interfere with the display of my humble listviews? I’ll have a talk with my systems administrator.
The absense of my colors is rather harmless though annoying. But does it reveal a bigger problem?
Klaas
Well professor, you do credit to your name.
Well actually one of the animators found the Ctrl Alt Del thing, and one of the IT guys suggested it was a mouse/keyboard driver (I had tried everything else short of a reformat, which I didn’t suggest since I knew it had to be some sort of driver conflict).
I really have no idea how or why this happens. I haven’t noticed anything strange happening with the listview otherwise, though, so I wouldn’t worry about larger problems (Max has enough larger problems as is).
We’ve reinstalled new mouse-drivers on two of the failing machines. It fixed the problem on one of these machines (leaving my IT-guy flabbergasted) but it didn’t fix the problem on the other. So we’re going to try a new mouse including new drivers.
Anyway, thanks for the insight and solution.
Klaas
no idea if this will help but maybe try puting lv.BeginUpdate() and lv.EndUpdate() at the begining and end of your fn_populateListview function respectively. This should stop any redrawing of the listview while your updating it which might have something to do with it but its just a guess