I know there is an easy and logical explenation to my problem, but I cant find it.
So: I have a form named Person, with comboBox1 for name, texBox1 for username, textBox2 for password and texBox3 for role. ComboBox1 has a datasource on table Oseba with the same coloumns as above plus IDP (primary key). DisplayMember on comboBox1 is name and ValueMember is IDP.
I select the name from comboBox1 and using comboBox1_SelectedValueChanged it fills the rest of the textBoxes with their values.
The form actually works good, the problem is, when I close the form. it throws me the "famous": Object reference not set to an instance of an object.
Code:
private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
{
ordinacijadbDataSet.PersonRow foundRow=
ordinacijadbDataSet.Person.FindByIDP(Convert.ToInt32(comboBox1.SelectedValue));
textBox1.Text = foundRow.Username.ToString(); <----- THE ERROR POINTS HERE
textBox2.Text = foundRow.Password.ToString();
textBox3.Text = foundRow.Role.ToString();
}
As I said, the form works like it should, until i try to close it. I cant figure out the problem.
Plese help