| View previous topic :: View next topic |
| Author |
Message |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Mon Jul 09, 2007 2:00 pm Post subject: Problem with TListBox |
|
|
im making a media player and to try to figure out how to make a played songs list that you can click on and replay the song i did a code test
when i try to play a song on the list it takes the previous line and adds it
you can see this by the listbox1.items.add command
any ideas?
_________________
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Mon Jul 09, 2007 6:50 pm Post subject: |
|
|
| You're trying to make clicking an item on the listbox pass whatever song you click to replay... but you're adding shit from the listbox itself to the listbox? Color me baffled as to exactly what you're tying to achieve.
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Mon Jul 09, 2007 9:22 pm Post subject: |
|
|
its a catch to see whats being applied to the MediaPlayer
if you look at the commented code you can see i was trying with the mediaplayer
_________________
|
|
| Back to top |
|
 |
XTrinityX Expert Cheater
Reputation: 0
Joined: 18 May 2006 Posts: 123 Location: Connecticut
|
Posted: Tue Jul 10, 2007 1:05 am Post subject: |
|
|
Now, I don't have delphi open, but I think what you are trying to achieve could be done with:
| Code: | | mediaplayer1.url := listbox1.items[listbox1.selectedindex]; |
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Tue Jul 10, 2007 1:15 am Post subject: |
|
|
selectedIndex just returns a number I think.
selectedItem is what you're looking for.
|
|
| Back to top |
|
 |
XTrinityX Expert Cheater
Reputation: 0
Joined: 18 May 2006 Posts: 123 Location: Connecticut
|
Posted: Tue Jul 10, 2007 8:10 am Post subject: |
|
|
| slovach wrote: | selectedIndex just returns a number I think.
selectedItem is what you're looking for. |
Ya, it returns a number. When you do Listbox1.Items[number] , it returns the string at that number's index in the Listbox1.Items string array.
One thing though. I don't know whether Click events or Selected Index Changed events happen first. You may have to change the code to the Selected Index Changed events to get the correct index to return from Listbox1.SelectedIndex.
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Tue Jul 10, 2007 8:16 am Post subject: |
|
|
MediaPlayer1.URL := ListBox1.Items[ListBox1.selectedItem]
it cant find selectedItem identifier
_________________
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Tue Jul 10, 2007 8:56 am Post subject: |
|
|
listBox1.SelectedItem
or you could do it the SelectedIndex way above
e: is there a toString method kind of deal in delphi?
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Tue Jul 10, 2007 10:14 am Post subject: |
|
|
it doesnt give me that selection
wtfh
_________________
|
|
| Back to top |
|
 |
XTrinityX Expert Cheater
Reputation: 0
Joined: 18 May 2006 Posts: 123 Location: Connecticut
|
Posted: Tue Jul 10, 2007 10:46 am Post subject: |
|
|
its selectedindex not selecteditem...
MediaPlayer1.URL := Listbox1.Items[Listbox1.SelectedIndex];
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Tue Jul 10, 2007 10:52 am Post subject: |
|
|
i dont get that option
it wont compile
_________________
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Tue Jul 10, 2007 1:04 pm Post subject: |
|
|
| XTrinityX wrote: | | its selectedindex not selecteditem... |
Both of them exist. :O
|
|
| Back to top |
|
 |
|