>when you said separately do you mean that i can do the button call in the way: > >listbox1.CellBackgroundPaint ...
No, you can't do that. It might help to separate the problem into two parts. 1. Write code so that the listbox can draw each cell correctly. 2. Write code so that you can change what's displayed in the listbox. Part 1. The listbox will fire the CellBackgroundPaint event whenever it needs you to redraw any specific cell. If the entire listbox needs to be refreshed, the listbox will iterate through all the visible cells calling CellBackgroundPaint for each one. It tells you which cell to redraw by passing in the Row and Column of that specific cell. Within the CellBackgroundPaint event you use the Row and Column values to look up or calculate the correct shape and color to draw. You have to decide where to keep the data that determines what to draw in each cell. I think you said you have an array (aka vector) that lists the color for each cell. OK, so you need to access that array from the CellBackgroundPaint event to know the correct color to draw. Where do you keep that array? If it's global just reference it directly. If it's in the window then use the listbox's window property MyWindow(listbox.window).Myarray(row) Or better yet subclass the listbox and create a property where you can store a reference to your array. Or the solution that I usually prefer is to use the CellTag property for each row to store what needs to be drawn in that cell. Basically this means using a group of CellTags instead of your separate array. Listbox.CellTag(row,column) Part 2. Use ListBox1.InvalidateCell -1, 1 to tell the listbox you want it to redraw all the cells in the first column. This will fire a CellBackgroundPaint event for each visible cell in the first column. If you coded part 1 correctly then the cells will show their current status and color. > >i am having a hard time explaining over and over what im trying to do. > >1-i start with all balls on a column painted black >2- clicking a button updates a vector corresponding to each cell in a >column that supposedly changes the colors from black to other colors >independently for each cell, i.e. some will be changed to yellow, some >will be changed to red. >3- clicking a button again keeps updating the vector...and so on > >the solution you proposed works as long as i have hard coded what >color or color variable i have for each cell. No I proposed having an array or using cell tags to hold the colors, then use the ROW parameter in the CellaBackgroundPaint event to access and draw the right one. >if i declare lots of >color variables, one per cell, and for each cell i assign it to the >cell then it may work, however, it may not be the best solution. Is >there a function to code this dynamic change of color from outside? It's totally up to you to control the drawing in the CellBackgroundPaint event. Try the steps listed above and let us know how far you got. Tell us exactly where the array of colors is stored and show us the code you have in CellBackgroundPaint and we can make better recommendations. Hope this helps, Joe Huber _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives: <http://support.realsoftware.com/listarchives/lists.html>
