Checkmark Primitive Color for TriState

2 posts, 0 answers
  1. Ian
    Ian avatar
    61 posts
    Member since:
    Jul 2010

    Posted 12 Nov 2012 Link to this post

    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;
  2. Boryana
    Admin
    Boryana avatar
    330 posts

    Posted 15 Nov 2012 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top