Hi @chuanzhen the fact that the first time (when nothing is selected) correctly respect the COLOR_TEXT is kind of a bug for treeview containing only LV_USER.
When you are using LV_USER the DrawCell method is called and you are responsible to define the color of your text via DrawSetTextCol. But if you do not set any text color, the GeUserArea will use the previously defined color. Which is in this case COLOR_TEXT when nothing is selected. Then when you select something, the last call of this DrawSetTextCol
internally done by Cinema 4D define it to "white" color so that's why all texts are white. Then when there is one column that is defined as LV_TREE it will then call DrawSetTextCol with the correct color (COLOR_TEXT or COLOR_TEXT_SELECTED) and therefor your call DrawText will use this color.
So with that's said, do not forget to manage your color in your DrawCell method something like that:
txtColorDict = canvas.GetColorRGB(c4d.COLOR_TEXT_SELECTED) if obj.IsSelected else canvas.GetColorRGB(c4d.COLOR_TEXT)
txtColorVector = c4d.Vector(txtColorDict["r"]/255.0, txtColorDict["g"]/255.0, txtColorDict["b"]/255.0)
canvas.DrawSetTextCol(txtColorVector, bgColor)
canvas.DrawText(text, xpos, ypos)
Cheers,
Maxime.