I have sucessfully populated a datagrid view from a list. The problem lies with trying to change the data source after a search has been initiated.
I'm sucessfully returning intended results from the below code.
int ResultIndex = 0;
for (int i = 0; i < Members.Count; i++)
{
if (Members[i].ToonName == ToonSearchName.Text)
{
ResultIndex = i;
break;
}
}
var Source = new BindingSource();
MessageBox.Show(ResultIndex.ToString()); // Returns the correct Index
MessageBox.Show(Members[ResultIndex].ID); // Returns the correct value
MemberListView.AutoGenerateColumns = true;
MemberListView.Columns.Clear();
MemberListView.DataSource = this.Members[ResultIndex]; // Datagrid view turns blank after this line
The actual list is as followed:
public class DVMemberlist
{
public string ID { get; set; }
public string ToonName { get; set; }
public string AddedOn { get; set; }
public string AddedBy { get; set; }
public string Enteries { get; set; }
}
It seems even know i'm able to print expected data into the message box, when trying to change the data source for the datagridview it empties and is blank rather showing 1 row.
First picture is the populated data when the form is loaded. Which is exactly as intended.
The second image is after the search has been performed for "Ocz7ok3MqH" which message boxes show the intended ID and the intended index. But the datagridview is returned blank