In the ItemCheck handler of a checked ListView, how to find the Item.text value of the row whose che

  • Thread starter Thread starter sherifffruitfly
  • Start date Start date
S

sherifffruitfly

Hi,

Here's a skeleton-handler of what I'm trying to do:

private void editBbListView_ItemCheck(object sender,
System.Windows.Forms.ItemCheckEventArgs e)
{
string qEnabled = "";
string indexid = ITEM_IN_ROW_WHOSE_CHECK_JUST_CHANGED.Text;

(Update the database linked to the listview, based upon
indexid)
}

How do I determine ITEM_IN_ROW_WHOSE_CHECK_JUST_CHANGED?

I know how to determine, for example the item.text of the currently
selected row, if any. But that doesn't help here, since you can check
on/off a row without actually selecting the row.

Thanks for any ideas,

cdj
 
ItemCheck is called *before* the item is changed. If you want to do
something after the item has been changed, use ItemChecked instead. You can
use e.Index to determine the item that is being processed, e.CurrentValue to
determine its current state and e.New Value to get/set the new state.
 
ListView.ItemCheck event:
theListView.Items[e.Index]
Note this event occurs before the check state changes.
To determine new value, check e.NewValue. You have a chance for
validation and cancel the change by setting e.NewValue to something
else, e.g. e.NewValue = e.CurrentValue.

ListView.ItemChecked event:
just use: e.Item.

Thi
http://thith.blogspot.com
 
Peter said:
ItemCheck is called *before* the item is changed. If you want to do
something after the item has been changed, use ItemChecked instead. You can
use e.Index to determine the item that is being processed, e.CurrentValue to
determine its current state and e.New Value to get/set the new state.

e.Index - thank you!
 
Back
Top