Click here to Skip to main content
15,919,245 members
Home / Discussions / C#
   

C#

 
GeneralRe: "Overloading" delegate Pin
leppie5-Sep-04 22:43
leppie5-Sep-04 22:43 
GeneralRe: "Overloading" delegate Pin
Paul Selormey5-Sep-04 22:55
Paul Selormey5-Sep-04 22:55 
GeneralRe: "Overloading" delegate Pin
leppie5-Sep-04 23:24
leppie5-Sep-04 23:24 
GeneralRe: "Overloading" delegate Pin
Paul Selormey6-Sep-04 0:32
Paul Selormey6-Sep-04 0:32 
GeneralRun one instance only Pin
jzb5-Sep-04 19:10
jzb5-Sep-04 19:10 
GeneralRe: Run one instance only Pin
Mazdak5-Sep-04 19:32
Mazdak5-Sep-04 19:32 
GeneralRe: Run one instance only Pin
mav.northwind5-Sep-04 20:07
mav.northwind5-Sep-04 20:07 
GeneralExchange Server Address Book Pin
FredSP5-Sep-04 18:18
FredSP5-Sep-04 18:18 
GeneralRe: Exchange Server Address Book Pin
Corinna John5-Sep-04 20:42
Corinna John5-Sep-04 20:42 
GeneralRe: Exchange Server Address Book Pin
FredSP6-Sep-04 2:49
FredSP6-Sep-04 2:49 
GeneralRe: Exchange Server Address Book Pin
Corinna John6-Sep-04 3:41
Corinna John6-Sep-04 3:41 
GeneralSocket remote node disconnection Pin
Den2Fly5-Sep-04 18:08
Den2Fly5-Sep-04 18:08 
GeneralRe: Socket remote node disconnection Pin
Pradeep Shamarao5-Sep-04 21:47
Pradeep Shamarao5-Sep-04 21:47 
GeneralCustomizing a ListBox Pin
eggie55-Sep-04 16:58
eggie55-Sep-04 16:58 
GeneralRe: Customizing a ListBox Pin
mav.northwind6-Sep-04 2:35
mav.northwind6-Sep-04 2:35 
GeneralRe: Customizing a ListBox Pin
Werdna6-Sep-04 9:49
Werdna6-Sep-04 9:49 
GeneralRe: Customizing a ListBox Pin
eggie56-Sep-04 19:32
eggie56-Sep-04 19:32 
Hey man, thanks for you help. I have made an implimentation of it below.

namespace listBoxTest
{
    partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Customer customer=new Customer(this.textBox1.Text, this.textBox2.Text);

            this.listBox1.Items.Add(customer.firstName);
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Customer cust=(Customer)listBox1.SelectedItem;

            this.asdfStatusStripPanel.Text=cust.firstName+" "+cust.lastName;
        }
    }

    public class Customer
    {
        public string firstName;
        public string lastName;

        public Customer(string FirstName, string LastName)
        {
            firstName = FirstName;
            lastName = LastName;
        }
    }
}


My question was regarding the code inside my listBox1_SelectedIndexChanged and the button1_Click methods. When I just add a Customer to the listBox all the code works fine, but I can't see any firstName or lastName in the listBox (which is completely understandable). Now, when I add a Customer.firstName, does that now copy the whole Customer object to the list, or does it just copy the firstName object? I think it just copyies the object (string) firstName, 'cause in listBox1_SelectedIndexChanged when I try to add the data to the class, I get an InvalidCastException.

Any idea how I can still add the (string) representation of the Customer.firstName to the ListBox, but still have access to the whole object (class) in the listBox1_SelectedIndexChanged method?

/\ |_ E X E GG
GeneralRe: Customizing a ListBox Pin
Werdna7-Sep-04 3:59
Werdna7-Sep-04 3:59 
GeneralRe: Customizing a ListBox Pin
eggie57-Sep-04 14:01
eggie57-Sep-04 14:01 
QuestionCan I use Visual C# Standard commercially? Pin
kusanagi20005-Sep-04 15:35
kusanagi20005-Sep-04 15:35 
AnswerRe: Can I use Visual C# Standard commercially? Pin
Christian Graus5-Sep-04 15:38
protectorChristian Graus5-Sep-04 15:38 
GeneralRe: Can I use Visual C# Standard commercially? Pin
kusanagi20005-Sep-04 16:33
kusanagi20005-Sep-04 16:33 
GeneralGradientPanel Pin
Asciono5-Sep-04 13:29
Asciono5-Sep-04 13:29 
GeneralRe: GradientPanel Pin
mav.northwind5-Sep-04 20:10
mav.northwind5-Sep-04 20:10 
GeneralMachine Info Pin
Moon Boy5-Sep-04 13:17
Moon Boy5-Sep-04 13:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.