I have a datagridview, and I want to remove a particular row from it (datagridview is not data bound). To remove, I need the index of the row. Datagridview items are all objects. At this moment, all I have is the id (a property) of the object. I want to know the index of the row in datagridview which holds the object of id, say 2.
How do I accomplish this? Or is there another way of deleting a row based on an object’s value?
There’s probably a cleaner way, but with LINQ:
and without LINQ: