G
Greg
I'm trying to display record information in labels, I've
got a listview filled with records and when you click on
one of them I want that record's information shown in
several labels. This is how I'm trying to do it:
private void listView_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
// gets currently selected record
li = listView.GetItemAt(e.X,e.Y);
}
private void listView_SelectedIndexChanged(object sender,
System.EventArgs e)
{
if( li != null )
lblNum.Text = li.SubItems[0].Text;
}
With this code li is always null! li is getting set
because my other functions have been using it fine, it
seems that when it tries to access it at this point it's
always null no matter what. I've also tried putting the
line 'lblNum.Text = li.SubItems[0].Text;' right below 'li
= listView.GetItemAt(e.X,e.Y);' but it never updates the
label. Any suggestions?
Thanks,
Greg
got a listview filled with records and when you click on
one of them I want that record's information shown in
several labels. This is how I'm trying to do it:
private void listView_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
// gets currently selected record
li = listView.GetItemAt(e.X,e.Y);
}
private void listView_SelectedIndexChanged(object sender,
System.EventArgs e)
{
if( li != null )
lblNum.Text = li.SubItems[0].Text;
}
With this code li is always null! li is getting set
because my other functions have been using it fine, it
seems that when it tries to access it at this point it's
always null no matter what. I've also tried putting the
line 'lblNum.Text = li.SubItems[0].Text;' right below 'li
= listView.GetItemAt(e.X,e.Y);' but it never updates the
label. Any suggestions?
Thanks,
Greg