RADListBox Bind Description Text

2 posts, 0 answers
  1. Gourangi
    Gourangi avatar
    83 posts
    Member since:
    Mar 2008

    Posted 17 Feb 2009 Link to this post

    Hi,

    How can I bind a runtime value in description text property of ListBox Item !
    Like there should be databind property (field name) for description text !

    Regards,
    Divyesh Chapaneri
  2. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 17 Feb 2009 Link to this post

    Hello Divyesh Chapaneri,

    Thank you for the question.

    You can use the ItemDataBound event for your scenario. Although the linked help article is in the RadComboBox section, it is also valid for RadListBox. The code snippet in your case will be similar to the shown below:
    public Form1()  
    {  
        InitializeComponent();  
     
        this.radListBox1.ItemDataBound += new Telerik.WinControls.UI.ItemDataBoundEventHandler(radListBox1_ItemDataBound);  
        this.radListBox1.DataSource = this.customersBindingSource;  
        this.radListBox1.DisplayMember = "ContactName";  
        this.radListBox1.ValueMember = "CustomerID";  
    }  
     
    private void Form1_Load(object sender, EventArgs e)  
    {  
        // TODO: This line of code loads data into the 'nwindDataSet.Customers' table. You can move, or remove it, as needed.  
        this.customersTableAdapter.Fill(this.nwindDataSet.Customers);  
    }  
     
    void radListBox1_ItemDataBound(object sender, Telerik.WinControls.UI.ItemDataBoundEventArgs e)  
    {  
        RadListBoxItem item = e.DataBoundItem as RadListBoxItem;  
        item.DescriptionText = ((DataRowView)e.DataItem).Row["ContactTitle"].ToString();  

    If you have additional questions, feel free to contact me.

    All the best,
    Nikolay
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top