ItemCheckEventArgs Class
Collapse the table of content
Expand the table of content

ItemCheckEventArgs Class


Provides data for the ItemCheck event of the CheckedListBox and ListView controls.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)


public class ItemCheckEventArgs : EventArgs

System_CAPS_pubmethodItemCheckEventArgs(Int32, CheckState, CheckState)

Initializes a new instance of the ItemCheckEventArgs class.


Gets a value indicating the current state of the item's check box.


Gets the zero-based index of the item to change.


Gets or sets a value indicating whether to set the check box for the item to be checked, unchecked, or indeterminate.


Determines whether the specified object is equal to the current object.(Inherited from Object.)


Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)


Serves as the default hash function. (Inherited from Object.)


Gets the Type of the current instance.(Inherited from Object.)


Creates a shallow copy of the current Object.(Inherited from Object.)


Returns a string that represents the current object.(Inherited from Object.)

The ItemCheck event occurs when the checked state of an item in a checked list box changes. The ItemCheckEventArgs class specifies the index of the item to change, the current value of the check box for the item, and the new value to set for the check box.

For more information about handling events, see Handling and Raising Events.

The following code example demonstrates a checked ListView control that handles the ListView.ItemCheck event. The method uses the CurrentValue and Index properties of the ItemCheckEventArgs object to retrieve and tally the price of the menu items selected. To run this example paste the following code in a form containing a ListView named ListView1 and a TextBox named Textbox1. Call the InititalizeListView method from the form's constructor or Load method. Ensure all events are associated with their event-handling methods.

private void InitializeListView()
	this.ListView1 = new System.Windows.Forms.ListView();

	// Set properties such as BackColor and DockStyle and Location.
	this.ListView1.BackColor = System.Drawing.SystemColors.Control;
	this.ListView1.Dock = System.Windows.Forms.DockStyle.Top;
	this.ListView1.Location = new System.Drawing.Point(0, 0);
	this.ListView1.Size = new System.Drawing.Size(292, 130);
	this.ListView1.View = System.Windows.Forms.View.Details;
	this.ListView1.HideSelection = false;

	// Allow the user to select multiple items.
	this.ListView1.MultiSelect = true;

	// Show CheckBoxes in the ListView.
	this.ListView1.CheckBoxes = true;

	//Set the column headers and populate the columns.
	ListView1.HeaderStyle = ColumnHeaderStyle.Nonclickable;

	ColumnHeader columnHeader1 = new ColumnHeader();
	columnHeader1.Text = "Breakfast Choices";
	columnHeader1.TextAlign = HorizontalAlignment.Left;
	columnHeader1.Width = 146;

	ColumnHeader columnHeader2 = new ColumnHeader();
	columnHeader2.Text = "Price Each";
	columnHeader2.TextAlign = HorizontalAlignment.Center;
	columnHeader2.Width = 142;


	string[] foodList = new string[]{"Juice", "Coffee", 
		"Cereal & Milk", "Fruit Plate", "Toast & Jelly", 
		"Bagel & Cream Cheese"};

	string[] foodPrice = new string[]{"1.09", "1.09", "2.19", 
		"2.79", "2.09", "2.69"};

	int count;

	// Members are added one at a time, so call BeginUpdate to ensure 
	// the list is painted only once, rather than as each list item is added.

	for(count = 0; count < foodList.Length; count++)
		ListViewItem listItem = new ListViewItem(foodList[count]);

	//Call EndUpdate when you finish adding items to the ListView.
double price = 0.0;

// Handles the ItemCheck event. The method uses the CurrentValue
// property of the ItemCheckEventArgs to retrieve and tally the  
// price of the menu items selected.  
private void ListView1_ItemCheck1(object sender, 
	System.Windows.Forms.ItemCheckEventArgs e)
	if (e.CurrentValue==CheckState.Unchecked)
		price += Double.Parse(
	else if((e.CurrentValue==CheckState.Checked))
		price -= Double.Parse(

	// Output the price to TextBox1.
	TextBox1.Text = price.ToString();

.NET Framework
Available since 1.1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
© 2015 Microsoft