Set ForeColor for list element

2 posts, 1 answers
  1. Victoria F
    Victoria F avatar
    46 posts
    Member since:
    May 2010

    Posted 30 Sep 2011 Link to this post

    Editing UI Elements and trying to code it does not have any effect on the RadDropDownList ddb_1.
    The SELECTED item in the box is blue. Which is good. But all items in the list are still black...

    ddb_1.DropDownListElement.ForeColor = Color.FromArgb(21, 66, 139);
    ddb_1.DropDownListElement.ListElement.ForeColor = Color.FromArgb(21, 66, 139);
    ddb_1.DropDownListElement.ListElement.ElementTree.RootElement.ForeColor = Color.FromArgb(21, 66, 139);

    Please , help me to make list items in the list blue color.  Please see attached pictures.
    Same problem with the treeview...
  2. Answer
    Ivan Petrov
    Ivan Petrov avatar
    718 posts

    Posted 04 Oct 2011 Link to this post

    Hi Victoria F,

    Thank you for writing and for the attached screen shots.

    Both these controls take advantage of the virtualization technology. This is why you have to use the formatting events to change the look of the items. You can use the nested RadListControl VisualItemFormatting event to change the fore color of the items in the drop down list. In addition, you have to change the fore color of the drop down editable area element. For the RadTreeView you can use the NodeFormatting event. Here is a code snippet which demonstrates all of the above:

    public Form1()
      this.radDropDownList1.ListElement.VisualItemFormatting += new VisualListItemFormattingEventHandler(ListElement_VisualItemFormatting);
      this.radTreeView1.NodeFormatting +=new TreeNodeFormattingEventHandler(radTreeView1_NodeFormatting);
      this.radDropDownList1.DropDownListElement.EditableElement.ForeColor = Color.FromArgb(21, 66, 139);
    void ListElement_VisualItemFormatting(object sender, VisualItemFormattingEventArgs args)
      args.VisualItem.ForeColor = Color.FromArgb(21, 66, 139);
    private void radTreeView1_NodeFormatting(object sender, TreeNodeFormattingEventArgs e)
      e.Node.ForeColor = Color.FromArgb(21, 66, 139);

    I hope this will help. If you have further questions, I would be glad to help. Greetings,
    Ivan Petrov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top