[Closed] XtraTreeList backcolor not working
does anyone else have a problem setting the backcolor of the XtraTreeList control? i can set the backColor and when i check its .R .G .B properties it returns the correct values but the background of the control just stays white… maybe i’m missing a flag somewhere?
example code:
global testRoll
try(DestroyDialog testRoll)catch()
rollout testRoll "testRoll"
(
dotnetcontrol tv "DevExpress.XtraTreeList.TreeList" width:204 height:300 pos:[0,0]
label lab_color1 "TreeList.BackColor is:" align:#left
label lab_color2 ""
fn addColumn caption width visible:true fixedSide:undefined =
(
local col = tv.Columns.Add()
col.caption = caption
col.width = width
col.visible = visible
if fixedSide != undefined do col.Fixed = getProperty col.Fixed fixedSide
col.optionsColumn.AllowEdit = false
col.optionsColumn.AllowMove = false
col.optionsColumn.AllowSize = false
col.optionsColumn.AllowSort = false
col
)
fn initTreeList =
(
-- Set up the treelist
tv.OptionsBehavior.Editable = false
tv.OptionsBehavior.ResizeNodes = false
tv.OptionsMenu.EnableColumnMenu = false
tv.OptionsView.ShowIndicator = false
-- add the columns
tv.BeginUpdate();
addColumn "col 1" 100
addColumn "col 2" 50
addColumn "col 3" 50
tv.EndUpdate()
local c = colorMan.GetColor #background * 255
tv.backColor = tv.backColor.fromARGB c.x c.y c.z
format "%
" (tv.BackColor.ToString())
lab_color2.text = tv.BackColor.ToString()
)
fn UpdateTreeList =
(
tv.Nodes.Clear()
tv.BeginUnboundLoad()
for i = 1 to 3 do
(
root = local root = tv.AppendNode #("root " + i as string, "", "") -1
for j = 1 to (random 1 3) do
tv.AppendNode #("sub " + j as string, "x", "y") root
)
tv.ExpandAll()
tv.EndUnboundLoad()
)
on testRoll open do
(
clearListener()
initTreeList()
UpdateTreeList()
)
)
createDialog testRoll width:204
hey man, I don’t know the exact solution to your problem, but depending on what your needs are and what you are trying to do – an alternative you can use is Python & PyQt.
This may be not what you’re looking for, but for us at Blur it was a much appreciated way to completely bypass the dotNet experience – all you’d need to get going is available at http://blur-dev.googlecode.com
& this is what your code would look like in python:
from Py3dsMax import mxs
from blur.wingui import Dialog
from PyQt4.QtGui import QColor
from PyQt4.QtGui import QHBoxLayout
from PyQt4.QtGui import QLabel
from PyQt4.QtGui import QPalette
from PyQt4.QtGui import QTreeWidget
from PyQt4.QtGui import QTreeWidgetItem
from PyQt4.QtGui import QVBoxLayout
class MyDialog( Dialog ):
def __init__( self ):
Dialog.__init__( self )
self.resize( 204, 400 )
tree = QTreeWidget( self )
label = QLabel( self )
label.setText( 'BackColor is:' )
label2 = QLabel( self )
hlayout = QHBoxLayout()
hlayout.addWidget( label )
hlayout.addWidget( label2 )
layout = QVBoxLayout()
layout.addWidget( tree )
layout.addLayout( hlayout )
layout.setContentsMargins( 0, 0, 0, 0 )
self.setLayout( layout )
self.uiMainTREE = tree
self.uiColorLBL = label2
self.initTree()
self.loadTree()
def initTree( self ):
# Set the columns
self.uiMainTREE.setColumnCount( 3 )
self.uiMainTREE.setHeaderLabels( [ 'col 1', 'col 2', 'col 3' ] )
mcolor = mxs.colorMan.getColor( 'background' ) * 255
qcolor = QColor( mcolor.x, mcolor.y, mcolor.z )
palette = self.uiMainTREE.palette()
palette.setColor( QPalette.Base, qcolor )
self.uiMainTREE.setPalette( palette )
self.uiColorLBL.setText( '(%s,%s,%s)' % (qcolor.red(),qcolor.green(),qcolor.blue()) )
def loadTree( self ):
import random
self.uiMainTREE.clear()
for i in range( 3 ):
root = QTreeWidgetItem( [ 'root %02i' % i ] )
for j in range( random.randrange( 1, 3 ) ):
root.addChild( QTreeWidgetItem( [ 'sub %02i' % j, 'x', 'y' ] ) )
self.uiMainTREE.addTopLevelItem( root )
root.setExpanded( True )
MyDialog().show()
thanks for the rewrite! unfortunately i’m still going the dotnet / maxscript approach for this project at least. But I’ll definitely be looking into python for the future.