Hide DisplayMember in ListControl

3 posts, 0 answers
  1. Robert
    Robert avatar
    23 posts
    Member since:
    Feb 2009

    Posted 01 Jun 2011 Link to this post

    I'm creating a custom VisualItem control that I'd like to use to display items in the ListControl.

    My problem is that I don't seem to be able to get the control to stop displaying the DisplayMember text. If I set DisplayMember to None, it displays the type name information for the object.

    How can I prevent this text from being displayed?
  2. Robert
    Robert avatar
    23 posts
    Member since:
    Feb 2009

    Posted 01 Jun 2011 Link to this post

    I resolved this by setting the Text property of the data item to an empty string, but I'd love to know if there is a better way.

    Here is what I did:

    private void myListBox_ItemDataBinding(object sender, ListItemDataBindingEventArgs args)
    {
        args.NewItem = new MyCustomDataItem();
        args.NewItem.Text = string.Empty;
    }
  3. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 06 Jun 2011 Link to this post

    Hi Robert,

    Thank you for writing.

    There is another way to hide the text - you can set the DrawText property to false on the VisualItemFormatting event.

    this.radDropDownList1.VisualListItemFormatting += new VisualListItemFormattingEventHandler(radDropDownList1_VisualListItemFormatting);
            
     
         void radDropDownList1_VisualListItemFormatting(object sender, VisualItemFormattingEventArgs args)
         {
             args.VisualItem.DrawText = false;
         }

    I hope this helps.

    Greetings,
    Peter
    the Telerik team
    Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
Back to Top