Display single row of object data in a datagridview after selecting an item from combo box
<p>I have a class <code>Person</code> with data members <code>fullName</code>, <code>adress</code>, <code>occupation</code>.</p>

<p>I made a <code>List</code> of the type <code>Person</code> and stored inside of it a couple of objects of type <code>Person</code>.</p>

<p>There's a combo box, and a datagridview on my Windows Forms GUI.</p>

<p>What I wanted to do is when you select an item from the combo box(it gets populated automatically with <code>Persons</code> objects from the <code>List</code>) datagridview displays a single row, showing the currently selected item's <code>fullName</code> and <code>address</code>.</p>

<p>For getting the information about a person from the list I use a method I created - <code>PersonInfo(string id)</code>. This method returns the <code>Person</code> object. Then I use that object like so:</p>

<pre><code>private void combobox_SelectedValueChanged(object sender, EventArgs e)
{ 
Person myObj = PersonInfo(combobox.SelectedText.ToString());
dataGridView1.Rows.Clear();
int index = dataGridView1.Rows.Add();
DataGridViewRow row = dataGridView1.Rows[index];
row.Cells["cFullName"].Value = myObj.fullName;
row.Cells["cAddress"].Value = myObj.address;
}
</code></pre>

<p>Problem is I get a null exception which is usually located at the line <code>row.Cells["cFullName"].Value = myObj.fullName;</code>. I think <code>combobox.SelectedText.ToString()</code> is what causing this but don't know which other method to use to grab info from combo box and pass it to the <code>PersonInfo</code>.</p>
