jhop310's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
New Members
Active Posts:
13 (0.02 per day)
Joined:
30-October 12
Profile Views:
196
Last Active:
User is offline Sep 12 2014 01:28 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   jhop310 has not set their status

Posts I've Made

  1. In Topic: Moving listbox selection to a new listbox in a new form. Homework Help

    Posted 12 Sep 2014

    Okay so looking through your tutorial on debugging (Sorry they don't teach this in my computer science courses at Uni) I get a NullReference Exception Unhandled error. Then looking through for the null values like your tutorial says, i find that listBox1 is null when i am trying to add item to it. This has me utterly confused. I tried inserting a breakpoint at the SelectedIndex and it showed that item was holding the correct information from the form1 listbox.
  2. In Topic: Moving listbox selection to a new listbox in a new form. Homework Help

    Posted 12 Sep 2014

    Wow your right i did need to walk away from it for a bit. I came back to it today and found it right away, i was throwing that error myself. Now i'm running into the a problem that the new form isn't opening at all when i change the selected item in the listbox. Any help would be appreciated:

     public partial class Form2 : Form
        {
            public Form2()
            {
                InitializeComponent();
              
            }
    
            internal void Show(string item)
            {
                listBox1.Items.Add(item.ToString());
                
            }
    
            private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
            {
    
            }
        }
    }
    


    private void button1_Click(object sender, EventArgs e)
            {
                DialogResult result;
                string fileName;
    
                //Find and Open File
    
                OpenFileDialog selectFile = new OpenFileDialog();
                result = selectFile.ShowDialog();
                fileName = selectFile.FileName;
    
    
                try{
                    FileStream input = new FileStream(fileName,
                        FileMode.Open, FileAccess.Read);
                    fileReader = new StreamReader(input);
    
                }
                catch
                {
                    MessageBox.Show("That File is not valid");
                }
    
                try{
                    while(true)
                    {
                        string[] inputFields;
                        string inputLine = fileReader.ReadLine();
                        if (inputLine ==null)
                            return;
                        inputFields = inputLine.Split(',');
                        PersonEntry myObject = new PersonEntry(inputFields[0], 
                            inputFields[1], inputFields[2]);
                        PersonEntry.myList.Add(myObject);
                        listBox1.Items.Add(myObject.ToString());
                    }
                    
                }
                    catch(IOException)
                {
                        MessageBox.Show("Data in the file was Invalid");
                    }
                }
    
            private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
            {
                string item = listBox1.SelectedItem.ToString();
    
                Form2 form2 = new Form2();
                form2.Show(item.ToString());
    
    
            }
    
  3. In Topic: Why does this output the List Name not the Text?

    Posted 12 Sep 2014

    Yeah something along those lines i ended up using:

     public override string ToString()
            {
                return "Name: " + pname + "Email: " + pemail
                    + "Phone Number:  " + pnumb;
            }
    


    Thanks again for your help!
  4. In Topic: Why does this output the List Name not the Text?

    Posted 11 Sep 2014

    I figured it out thanks for your help!
  5. In Topic: Why does this output the List Name not the Text?

    Posted 11 Sep 2014

    Sorry i didn't include my PersonEntry class, inside it i put a ToString method, although i guess its not quite working, can you point me in the right direction with it?

       class PersonEntry
        {
            //get and set properties
            public string pname{ get; set; }
            public string pemail{ get; set; }
            public string pnumb{ get; set; }
    
            //Constructor with 3 arguments
            public PersonEntry(string name, string email, string number )
            {
                pname = name;
                pemail = email;
                pnumb = number;
            }
            public static List<PersonEntry> myList =
                new List<PersonEntry>();
            public override string ToString()
            {
                return base.ToString();
            }
           }
    }
    

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Click here to e-mail me

Friends

jhop310 hasn't added any friends yet.

Comments

jhop310 has no profile comments yet. Why not say hello?