Change DropDownList item color

7 posts, 0 answers
  1. miki
    miki avatar
    37 posts
    Member since:
    Dec 2014

    Posted 21 Dec 2014 Link to this post

    I have my object and all it's properties that i want to populate inside my DropDownList and i am doing this in this way:

                DescriptionTextListDataItem item = new DescriptionTextListDataItem();
                item.Text = "This is string test";
                radDropDownListAdapter.Items.Add(item);
                string str1 =
                    "Name:: " + "test 1" + Environment.NewLine +
                    "Age:: " + "test 2" + Environment.NewLine +
                    "ID: : " + "test 3" + Environment.NewLine +
                    "Scor: " + "test 4" + Environment.NewLine;

                item.DescriptionText = str1;
                radDropDownListAdapter.SelectedIndex = 0;

    Currently i am using VisualStudio2012Light theme and you can see the result in my attach file.
    As you can see all my object propertiesrarely seen because it's black and background is blue so my question is how to change this color from black ?

  2. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 24 Dec 2014 Link to this post

    Hi Miki,

    Thank you for writing.

    I managed to reproduce the described case and I can confirm it is an issue. I have logged it in our feedback portal. You can add your vote and subscribe for status updates here: http://feedback.telerik.com/Project/154/Feedback/Details/147335-fix-raddropdownlist-the-description-text-is-not-clearly-visible-for-the-select.

    Your Telerik Points have been updated for this report. 

    To change the color, you can use the VisualItemFormatting event as show below:
    void radDropDownList1_VisualListItemFormatting(object sender, VisualItemFormattingEventArgs args)
    {
        if (args.VisualItem.Selected && radDropDownList1.ThemeName == "VisualStudio2012Dark")
        {
            args.VisualItem.BackColor = Color.DarkBlue;
        }
        else
        {
            args.VisualItem.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
        }
    }

    I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us.

    Regards,
    Stefan
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for WinForms is Visual Studio 2017 Ready
  4. miki
    miki avatar
    37 posts
    Member since:
    Dec 2014

    Posted 24 Dec 2014 in reply to Stefan Link to this post

    Hi and thank you for your help.
    Currently there is no change and the color is still the same.
  5. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 24 Dec 2014 Link to this post

    I have tested this code with our latest version and it was working correctly. Still, you can try the following snippet too:
    void radDropDownList1_VisualListItemFormatting(object sender, VisualItemFormattingEventArgs args)
    {
        if (args.VisualItem.Selected && radDropDownList1.ThemeName == "VisualStudio2012Dark")
        {
            args.VisualItem.DrawFill = true;
            args.VisualItem.BackColor = Color.DarkBlue;
            args.VisualItem.GradientStyle = GradientStyles.Solid;
        }
        else
        {
            args.VisualItem.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local);
            args.VisualItem.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
            args.VisualItem.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local);
        }
    }

    Just to make sure we are allowed to set the BackColor, we will set the DrawFill too.

    If this does not help, please get back to me with a sample app, where the undesired behavior can be reproduced and I will gladly look into it.

    Regards,
    Stefan
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  6. miki
    miki avatar
    37 posts
    Member since:
    Dec 2014

    Posted 25 Dec 2014 in reply to Stefan Link to this post

    I'm sorry if I was not clear, but what I meant is change the text color
  7. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 25 Dec 2014 Link to this post

    Hello,

    To do that, again in the formatting event, you should look for the DescriptionTextListVisualItem, and change the desired colors. You can even put different colors for the main text and the description text:
    void radDropDownList1_VisualListItemFormatting(object sender, VisualItemFormattingEventArgs args)
    {
        DescriptionTextListVisualItem descriptionItem = args.VisualItem as DescriptionTextListVisualItem;
        if (descriptionItem != null)
        {
            descriptionItem.ForeColor = Color.Blue;
            descriptionItem.DescriptionContent.ForeColor = Color.Red;
        }
    }

    I hope that you find this information useful.

    Regards,
    Stefan
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  8. miki
    miki avatar
    37 posts
    Member since:
    Dec 2014

    Posted 25 Dec 2014 in reply to Stefan Link to this post

    Thanks a lot !
    This is exactly what i am looking for.
Back to Top
UI for WinForms is Visual Studio 2017 Ready