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

Hide DisplayMember in ListControl

2 Answers 71 Views
ListControl
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 01 Jun 2011, 09:10 PM
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 Answers, 1 is accepted

Sort by
0
Robert
Top achievements
Rank 1
answered on 01 Jun 2011, 09:18 PM
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;
}
0
Peter
Telerik team
answered on 06 Jun 2011, 12:58 PM
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.
Tags
ListControl
Asked by
Robert
Top achievements
Rank 1
Answers by
Robert
Top achievements
Rank 1
Peter
Telerik team
Share this question
or