K
K
Kolya2015-06-18 14:48:31
C++ / C#
Kolya, 2015-06-18 14:48:31

"There is no suitable user-defined conversion." datagridview. What's wrong?

I'm deleting a row from a DataGridView on a button click, I don't know what the problem is

private: System::Void deleteBtn_Click(System::Object^  sender,
         System::EventArgs^  e) {
           for each (DataGridViewRow item in dataGridView->SelectedRows)
           {
             dataGridView->Rows->RemoveAt(item.Index);
           }
       }

9fb76db0318448a4b7bf186d4e55b89d.png
How to make this conversion?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Makarov, 2015-06-18
@Dev_Kpug

SelectedRows is a DataGridViewSelectedRowCollection , and it only implements a non-generic IEnumerable that returns System::Objects when enumerated. So do for each (System::Object^ item in dataGridView->SelectedRows) and then cast to the row explicitly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question