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

Set ForeColor for list element

1 Answer 161 Views
ListControl
This is a migrated thread and some comments may be shown as answers.
Victoria F
Top achievements
Rank 1
Victoria F asked on 30 Sep 2011, 06:05 PM
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...

1 Answer, 1 is accepted

Sort by
0
Accepted
Ivan Petrov
Telerik team
answered on 04 Oct 2011, 11:59 AM
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()
{
  InitializeComponent();
 
  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 >>

Tags
ListControl
Asked by
Victoria F
Top achievements
Rank 1
Answers by
Ivan Petrov
Telerik team
Share this question
or