Removing row pointed to by bound combo

  • Thread starter Thread starter Paul Aspinall
  • Start date Start date
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
 
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
 
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
 
Back
Top