Click here to Skip to main content
12,996,975 members (50,574 online)
Click here to Skip to main content


97 bookmarked
Posted 4 Sep 2006

Extending the ListBox to show more complex items

, 4 Sep 2006
This article shows how to extend the ListBox to show more complex items - for example, items with image and text areas.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace testexListBox
    public partial class Form1 : Form
        public Form1()

        private void Form1_Load(object sender, EventArgs e)
            Image image1 = Image.FromFile(@"image1.jpg");
            Image image2 = Image.FromFile(@"image2.jpg");
            Image image3 = Image.FromFile(@"image3.jpg");
            exListBox1.Items.Add(new exListBoxItem(14, "John, the Tester", @"First details text is used to check it out, if text fits correctly the bounds of an item.
As you can see, everything fits nicely.
If it's shown correctly, that's should be last line, that you see.
If you can see this line, it looks like it overlaps something and there's a bug in the code.
", image1));
            exListBox1.Items.Add(new exListBoxItem(99,"Bill", "phone +345645464, fax +6546546546, email", image2));
            exListBox1.Items.Add(new exListBoxItem(71, "Peter", "ICQ 56465464, msn, phone +5465464654", image3));


        private void exListBox1_DrawItem(object sender, DrawItemEventArgs e)

        private void exListBox1_SelectedIndexChanged(object sender, EventArgs e)
            this.Text = ((exListBoxItem)exListBox1.SelectedItem).Id.ToString();

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Lithuania Lithuania
No Biography provided

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170622.1 | Last Updated 4 Sep 2006
Article Copyright 2006 by GiedriusBan
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid