Removing row pointed to by bound combo

P

Paul Aspinall

Hi
I have a combo which is bound to a datatable.

I want to remove the record from the datatable, which the combo points to.

Can anyone confirm the correct syntax....
I believe it will be something like
datatable.Rows.Remove(.......??how do I find the row that is bound to the
combo??);

Thanks
 
C

Cor Ligthert

Paul,

You know that the "Remove" removes a datarow from a datatable and makes it
therefore impossible to update that to a database.

When you want to update it can than you need the datarowcollection.delete

When you have binded using the datasource a datatable to a combobox, than
you can use directly the selectedindex of that combobox (when it are not
listcontrols than you can better use the currencymanagager.position).

Therefore when you want to delete and not the remove you can use by instance

MyDatatable.Rows[MyCombobox.SelectedIndex].delete();

I hope this helps?

Cor
 
?

=?ISO-8859-2?Q?Marcin_Grz=EAbski?=

Hi,

In addition to Cor's answer...
If your ComboBox is bind to DataTable then "SelectedItem"
is a DataRow object(or DataRowView when DataView is source).

DataRow.Delete() should aim in your needs.

HTH
Marcin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top