title: Using an object as a DataGridViewRow
body: <p>Lets say I have a Person class with a name, telephone, email and a bool called selected.
  The persons are generated through a semi colon separated text file. 
  I loop the file and get the values for each person. What is the best practice for displaying them in a DataGridView with the columns "use" (checkbox for "selected"), "name", and "email"? (note that I'm leaving the telephone out)
  As it is now, i have a function called MakeDataGridRow in the Person class which i use something like this:</p>
  
  <pre><code>For each line blah blah StreamReader(filename) blah...
      Dim P as New Person(line.split(";"))
      MyDataGridview.Rows.Add(P.MakeDataGridRow)
  End For
  </code></pre>
  
  <p>This works, but this is not really good since when I wanna do something with the list, I have to loop the list and generate a new Person for every checked row, right? And in this case I can't get the telephone number since it's not in the list. I could save them in a list of persons (in the file read loop) and check every selected row against this list to get the telephone, but i don't like this solution.</p>
  
  <p>The nice solution would be if the Person class inherits DataGridViewRow so that when i loop my rows I can use the allready created Persons to check the phone number. How do i do this? </p>
  
  <p>some thing like:</p>
  
  <pre><code>Public Class Person
      Inherits DataGridViewRow
  
      Public Name As String
      Public Telephone as String
      Public Email As String
      Public Selected As Boolean
  
      Public Sub New(ByVal Values As String())
          Name = Values(0)
          Telephone = Values(1)
          Email = Values(2)
          Selected = True
      End Sub
  End Class
  </code></pre>
  
  <p>How can i display this class as a row in a DataGridView so that I later, when I do something with the persons, I can do something more like</p>
  
  <pre><code>For Each P as Person In MyDataGridView.Rows
      If P.Selected Then
          MsgBox(P.Name &amp; ", telephone: " &amp; P.Telephone)
      End If
  End For
  </code></pre>
  
  <p>I think you understand what I'm trying to achieve, any suggestions?</p>