Click here to Skip to main content
12,450,347 members (43,654 online)
Click here to Skip to main content

Stats

90K views
6.2K downloads
98 bookmarked
Posted

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()
        {
            InitializeComponent();
        }

        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 email@email.com", image2));
            exListBox1.Items.Add(new exListBoxItem(71, "Peter", "ICQ 56465464, msn hot@hotmail.com, 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.

License

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

Share

About the Author

GiedriusBan
Lithuania Lithuania
No Biography provided

You may also be interested in...

Pro
Pro
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160826.1 | Last Updated 4 Sep 2006
Article Copyright 2006 by GiedriusBan
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid