This is a migrated thread and some comments may be shown as answers.

Checkmark Primitive Color for TriState

1 Answer 115 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Ian
Top achievements
Rank 1
Ian asked on 13 Nov 2012, 12:48 AM
Hi Guys
I'd like to be able to set the color for the "TriState - Indeterminate" state of the checkbox on a treeview. I have the checkmarks set during NodeFormatting as follows but what element do I need to call to set the color of the black square that appears when the state is indeterminate?

Thanks & Regards
Ian Carson

((TreeNodeCheckBoxElement)e.NodeElement.Children[2]).CheckMarkPrimitive.CheckElement.ForeColor = Color.DarkGreen;

1 Answer, 1 is accepted

Sort by
0
Boryana
Telerik team
answered on 15 Nov 2012, 02:22 PM
Hi Ian,

Thank you for contacting us.

The style of the square that appears when the checkbox is in Indeterminate state can be controlled via the properties of the CheckPrimitive. For example, the following snippet applies different colors to the checked and indeterminate states:
private void radTreeView1_NodeFormatting(object sender, Telerik.WinControls.UI.TreeNodeFormattingEventArgs e)
{
    TreeNodeCheckBoxElement checkBox = e.NodeElement.Children[2] as TreeNodeCheckBoxElement ;
    if(checkBox != null)
    {
        if(checkBox.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On)
        {
            checkBox.CheckMarkPrimitive.CheckElement.ForeColor = Color.DarkGreen;
        }
        else if (checkBox.ToggleState == Telerik.WinControls.Enumerations.ToggleState.Indeterminate)
        {
            checkBox.CheckMarkPrimitive.CheckElement.ForeColor = Color.Orange;
            checkBox.CheckMarkPrimitive.CheckElement.BackColor = Color.Yellow;
            checkBox.CheckMarkPrimitive.CheckElement.BackColor2 = Color.DarkOrange;
        }
    }
}

For your convenience I have prepared a sample project that contains the above code sample. I hope you will find it useful.

Let me know if you have further questions on the matter. 

Regards,
Boryana
the Telerik team
Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
Tags
Treeview
Asked by
Ian
Top achievements
Rank 1
Answers by
Boryana
Telerik team
Share this question
or