I am trying to get the index of a listview item that has just being checked and update a database based on the item that was just checked not considering other items that were checked before I am trying to use the checkbox to indicate a user wants a notification or not, so when a user checks the checkbox, i want to use the index of the item and set notification for that item to true but i can only get all the checkeditems indexes at once.
Any help please.
I was able to call the itemcheck event function but it considers items checked initially as well as items checked by user. I managed to separate the items checked initially using a boolean function "Item_checked by user"
` private static bool checked_by_user;
private void courseworks_ItemCheck(object sender, ItemCheckEventArgs e)
{
if (checked_by_user == true)
{ //do something
}
else ;//do nothing
}`
Now, I want to be able to take the bar_ref_id of only the line that was just checked, My list view is created from a database as below
foreach (var item2 in CW_query2)//for each CW
{
if (item.Status == true)
{
ListViewItem items = new ListViewItem(new[] {//adds items into list view, per column
item2.Module_Code, item2.Title, item2.Due_Date.ToString("dd/MM/yy"),"Submitted",item.Bar_Ref_ID
});
courseworks.Items.Add(items);
}
else
{
ListViewItem items = new ListViewItem(new[] {//adds items into list view, per column
item2.Module_Code, item2.Title, item2.Due_Date.ToString("dd/MM/yy"),"Not-Submitted",item.Bar_Ref_ID
});
courseworks.Items.Add(items);
}
I hope my added info helps. Thanks in advance