Move DescriptionTextListDataItem Separator Line

2 posts, 1 answers
  1. Greg
    Greg avatar
    1 posts
    Member since:
    Jun 2010

    Posted 24 Oct 2012 Link to this post

    I'm currently using a RadDropDownList with a set of DescriptionTextListDataItems in DropDownList mode and it looks great except that it's drawing a thin gray separator line between the item text and the item description like this:

    Text
    ----------
    Description
    Text
    ----------
    Description


    Is there a way to remove this separator line and to have a separator line between the list items? What I'm looking for is something like this:

    Text
    Description
    ----------
    Text
    Description

    I'm not sure the way I'm doing it now is correct or the preferred way.

    private void SearchTypeList_CreatingVisualListItem(object sender, CreatingVisualListItemEventArgs e)
    {
        e.VisualItem.BorderColor = SystemColors.Control;
        //e.VisualItem.Children[0].Children[1].Children[1].ShouldPaint = false;
     
        foreach(var child in e.VisualItem.Children)
        {
            if(child is StackLayoutElement)
            {
                foreach(var child1 in child.Children)
                {
                    if(child1 is StackLayoutElement)
                    {
                        foreach(var child2 in child1.Children)
                        {
                            if(child2 is LinePrimitive)
                            {
                                child2.ShouldPaint = false;
                                return;
                            }
                        }
                    }
                }
            }
        }
    }

  2. Answer
    Peter
    Admin
    Peter avatar
    1148 posts

    Posted 29 Oct 2012 Link to this post

    Hi Gregory,

    Thank you for writing.

    You should set the DescriptionTextListVisualItem Visibility property to Hidden. Suitable place to do this is VisualListItemFormatting event. For example:
    this.radDropDownList1.VisualListItemFormatting += new Telerik.WinControls.UI.VisualListItemFormattingEventHandler(radDropDownList1_VisualListItemFormatting);
     
    void radDropDownList1_VisualListItemFormatting(object sender, Telerik.WinControls.UI.VisualItemFormattingEventArgs args)
    {
                DescriptionTextListVisualItem item = args.VisualItem as DescriptionTextListVisualItem;
                if (item != null)
                {
                    item.Separator.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
                }
    }

    I hope this helps. Greetings,
    Peter
    the Telerik team
    Q3’11 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