Alter ForeColor for disabled RadListDataItem

7 posts, 2 answers
  1. melkorman
    melkorman avatar
    16 posts
    Member since:
    Aug 2009

    Posted 19 Nov 2010 Link to this post

    Hi,

    I have a ListControl that contains among others some disabled ListDataItems. These list items are grayed out, but I would like them to show a bit more clearly, for example by setting the text color. I am using the Office2010 theme, so if possible I would like to use the same orange-ish color for the text of the disabled items as is used as background color for selected items in the list.

    Is this achievable?

    Best regards
    Linus
  2. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 19 Nov 2010 Link to this post

    Hello,

    It's not possible to alter the forecolor of a disabled item. You can change the font in this way
    For Each item As RadListDataItem In Me.RadListControl1.Items  
        If item.Enabled = False Then
            Dim FontName As String = "Arial"
            Dim FontSize As Integer = 8
            Dim myFont As New Font(FontName, FontSize, FontStyle.Regular)
            item.Font = myFont
        End If
    Next

    Hope that helps
    Richard
  3. UI for WinForms is Visual Studio 2017 Ready
  4. melkorman
    melkorman avatar
    16 posts
    Member since:
    Aug 2009

    Posted 19 Nov 2010 Link to this post

    Thank you very much for your answer!

    How unfortunate though! Will this be remedied in a future release?

    Linus
  5. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 19 Nov 2010 Link to this post

    Hello,

    I don't really see this as something which is an issue. It is usual to be able to set forecolor and backcolor and so on of controls that are enabled, but a usual state of a control that is not enabled is to be greyed-out. If you want it to stand out, you could always add an image to that item (it would appear as grey as well, but may make it stand out)

    Hope that helps
    Richard
  6. melkorman
    melkorman avatar
    16 posts
    Member since:
    Aug 2009

    Posted 19 Nov 2010 Link to this post

    Thanks again for answering!

    In general I agree that this is not an issue. A short explanation of my scenario might clarify why I still think that it would be a good feature:

    In my case, the list is populated with items depending on what is selected in a tree control. When a child node in the tree is selected, the list will contain items that are related both to the child node and the parent node(s). The items related to the parent node(s) have to be disabled, because they can not be deselected for the child node. The reason why they should be more clearly visualized is because they still influence the state of the child node in the tree.

    Hope that helps you understand the rationale behind my request. Maybe this scenario is better accomplished in some other way?
  7. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 19 Nov 2010 Link to this post

    Hi,

    without seeing your project it's difficult to say what might be the best way to achieve this. But it sounds like perhaps you should be changing the datasource for the list depending on the TreeNodes that you have selected?

    hope this helps
    Richard

    EDIT // Of course though, the fact that an item is not enabled, is a different color and is not selectable is a usual windows way of highlighting that something cannot be changed.
    Best regards,
    Richard
  8. Answer
    Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 24 Nov 2010 Link to this post

    Hello,

    Thank you for writing.

    Our theming mechanism allows for setting a specific style to an element when this element is in a disabled state. In regards to the case of Linus, the following steps should be completed:
    1. Open your theme in the Visual Style Builder and select RadListControl.
    2. Select RadListVisualItem in the tree of the RadListControl.
    3. In the Elements window expand RadListVisualItem and remove the property filter.
    4. Find the property UseDefaultDisablePaint and set it to false.

    These steps will allow for setting the text, fill and border of a RadListVisualItem when it is disabled.

    Sincerely yours,
    Dobry Zranchev
    the Telerik team
    Get started with RadControls for WinForms with numerous videos and detailed documentation.
Back to Top
UI for WinForms is Visual Studio 2017 Ready