I am coding a program and have this function where i need to delete a record. The current code i have at the moment deletes a record but only deletes the top record but i need it to delete the record the user has selected.

This is the current code:

DailyRoflGamingDatabaseDataSet1.Player.Rows(0).Delete()

Can anyone help me?

Welcome Tini791.

Your code show that you are deleting 1st record from the dataset and not from the listbox.

Please clarify it.

This should work where listbox1 is the name of your list box.

lstbox1.Items.Remove(listbox1.SelectedItem)

It deletes from both but i want it to delete the selected record and not the top record

This should work where listbox1 is the name of your list box.

lstbox1.Items.Remove(listbox1.SelectedItem)

I tried this code and when i tried runningit, it crashed when i tried using the function with this code :(

post your code

this was the original code:

DailyRoflGamingDatabaseDataSet1.Player.Rows(0).Delete()

then i tried it with that suggested code:

RemovePlayerListBox.Items.Remove(RemovePlayerListBox.SelectedItem)

when i tried this code it crashed my program

b89smith> Post your code.

Post your complete code so he/she can decide what you can do with your code?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.