7 Replies - 1677 Views - Last Post: 15 November 2010 - 02:45 PM Rate Topic: -----

#1 Ringlis  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 38
  • Joined: 29-October 10

Listbox help

Posted 13 November 2010 - 03:06 PM

I have a listbox called listbox1. When I run the program, I enter data into 5 textboxes & hit a button. This then displays the input in each textbox in the listbox.

When I click on the line of writting in the listbox, it displays the 5 textboxes with the data of that which I entered. If I change one textbox entry and hit the button, the listbox's display should update but it doesnt.

When I double click on the listbox, this is the code I have for it:

 if (listBox1.SelectedIndex > -1)
            {
                int index = listBox1.SelectedIndex;
                Bus myBus = myFleet.fleet.ElementAt(index);
                frmBus busGui = new frmBus();
                busGui.bus = myBus;
                busGui.Show();
                updateFleetList();
            }




My code above should ceate a new form for entering data which it does, take the data from the textboxes about the bus form, and load them into the listbox which it does. It is stored in a fleet list called myFleet.

updateFleetList(); I would of thought this would have updated the list but it doesnt appear to do so.

Have I missed something?

Is This A Good Question/Topic? 0
  • +

Replies To: Listbox help

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6036
  • View blog
  • Posts: 23,418
  • Joined: 23-August 08

Re: Listbox help

Posted 13 November 2010 - 03:08 PM

Moved to C# before you get pilloried. Don't post programming questions in the Lounge.
Was This Post Helpful? 0
  • +
  • -

#3 Ringlis  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 38
  • Joined: 29-October 10

Re: Listbox help

Posted 15 November 2010 - 03:25 AM

Ok, I'll bare that in mind, but am having trouble finding my question now under c#. Can you please send me the web page link to it so I can click on it and go directly to it so I may see if any solutions have been provide?

Thanks
Was This Post Helpful? 0
  • +
  • -

#4 biggerB  Icon User is offline

  • If at first you donít succeed, call it version 1.0
  • member icon

Reputation: 80
  • View blog
  • Posts: 760
  • Joined: 11-June 10

Re: Listbox help

Posted 15 November 2010 - 04:09 AM

Changing busGui.Show(); to busGui.ShowDialog; should fix the problem..

However it would be great if you could show me the updateFleetList Sub

This post has been edited by biggerB: 15 November 2010 - 04:10 AM

Was This Post Helpful? 0
  • +
  • -

#5 mavarazo  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 36
  • View blog
  • Posts: 181
  • Joined: 25-October 10

Re: Listbox help

Posted 15 November 2010 - 04:24 AM

Could you please post more of code.
Do you use Begin/EndUpdate() for the Listbox? Where is the data stored for the Listbox?
Was This Post Helpful? 0
  • +
  • -

#6 Ringlis  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 38
  • Joined: 29-October 10

Re: Listbox help

Posted 15 November 2010 - 05:08 AM

I tried that but still not updating the listbox with the data I input. Here is a copy of the code I have for the fleet list for the buses:

public List<Bus> fleet2     
        {
            get
            {
                return theFleet2;
            }
        }
        public void deleteFromFleet2(Bus aBus)  
        {
            theFleet2.Remove(aBus);
        }
        public void addToFleet2(Bus aBus)   
        {
            theFleet2.Add(aBus);
        }


Am not sue wher the code for editing is to go exactly as someone told me that its not to go in the listbox,(by double clicking on the listbox to embed the code there), so unsure now.

MOD EDIT: When posting code...USE CODE TAGS!!!

:code:
Was This Post Helpful? 0
  • +
  • -

#7 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6036
  • View blog
  • Posts: 23,418
  • Joined: 23-August 08

Re: Listbox help

Posted 15 November 2010 - 05:46 AM

After 20 posts, you should KNOW to use code tags!!! Please obey our rules and post your code in code tags!!!

:code:
Was This Post Helpful? 0
  • +
  • -

#8 Ringlis  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 38
  • Joined: 29-October 10

Re: Listbox help

Posted 15 November 2010 - 02:45 PM

Err...ok, my bad.

Well, finally got the problem sorted so that's another problem out the way, btu just thought I'd let you know.

Thanks for the help guys. If get anymore problems, will let you know
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1