Click here to Skip to main content
Click here to Skip to main content

Extending the ListBox to show more complex items

By , 4 Sep 2006
 
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 use 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

About the Author

GiedriusBan
Lithuania Lithuania
Member
No Biography provided

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