$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
ListView WinForms Control
Create elegant user interfaces, display data, group, filter, sort, and customize data items
Home > WinForms UI Controls > User Manual > ListView CheckBox and Editor in C#

ListView Built-in Checkboxes and Editors

Kettic ListView WinForms Control contains built-in checkboxes for data items and allows the users to editing the items in ListView in C#.NET. The Checkboxes of ListView items can be displayed by enable the DisplayCheckBoxes property and the ListView items editing feature can be enabled by changing the value of the ApplyEditing property to True. The checkboxes allows the users to check or uncheck each ListView item displayed and get or set the check state. The items editing feature allows the users to edit the label of the ListView items.

How to Manipulate Checkboxes in ListView in C#.NET

It is easy to manipulate the item checkboxes for ListView control. To enable this functionality to the ListView in your Windows Forms projects, we need to set the DisplayCheckBoxes property to True in ListView. After enabling the checkboxes, we can simply check or uncheck items through the checkbox displayed in each item, get or set the checked state of the ListViewDataItem through the CheckedState property, get the checked items in Kettic ListView from the CheckedItems collection. The ChangingCheckedItem and ChangedCheckedItem events will shows the changes in the check state of the items

How to Manipulate Editors in ListView in C#.NET

Kettic ListView allows the users to edit the ListView items. The default setting invokes the text editor and allows the users to edit the items label. To enable this functionality, we can set the ApplyEditing property to True and select an item to initiate the editing. After finishing the editing, the values will be assigned to the Value property of the items. The user can cancel the editing by using the Esc key. Kettic ListView also allows the users to initiate and cancel the editing process in C# code for their application. There are three methods available to accomplish this, the StartEdit() method, the EndEdit() method, and the CancelEdit() method. The StartEdit() method will initiate editing on the selected item, the EndEdit() method will end editing and save the edited value, and the CancelEdit() method will end the editing and discard the edited value. The C# code below shows how to editing using the C# API.

ketticListView1.ApplyEdit = true;
ketticListView1.SelectedItem = ketticListView1.Items[0];
ketticListView1.CurrentColumn = ketticListView1.Columns[0];
ketticListView1.StartEdit();

How to Edit Lifecycle in C#.NET

After we display an item in Kettic ListView control and initiate the editing mode, the StartEdit() method will be called, the ItemEditing event will be fired and a text box editor will appear in the selected item in the ListView. We can follow the steps below to edit the items for ListView.
  • The editor of ListView is able to control the handling of the keystroke, including cancels editing, enter ends editing and confirm changes
  • The action predefined by the enter key can be performed by the editor instance and will indicate the exiting of edit mode and saving of any changes.
  • In this step, we can call the EndEdit() method and fire the ItemValidating event.
  • The users can hook up custom logic for verification by using the ValidateValue event. If it fails, the ValidateError event is fired to present a notification as to the failure.
  • Cancel the process of assigning a new value to the item by following the ChangedItemValue event. If not, the new value will be assigned to the item and the ChangedItemValue event will be fired
The C# code below shows how to edit integer values by using the ValidateItem event.

void ketticListView1_ValidateItem(object sender, ListViewValidateItemEventArgs e)
{
int newInt = 0;
if (int.TryParse(Convert.ToString(e.NewValue), out newInt))
{
e.NewValue = newInt;
}
else
{
e.Cancel = true;
}
}

void ketticListView1_ValidateError(object sender, EventArgs e)
{
MessageBox.Display("Invalid");
}

How to Switch Editors in C#.NET

The EditorRequired event will be fired before the editing is performed. This event is able to replace the default text box editor with one of built-in editors, ListViewTextBoxEditor, ListViewDropDownListEditor, ListViewSpinEditor, and ListViewDateTimeEditor. Furthermore, the users can create custom instance as an editor. The C# code below demonstrates how to use the built-in editors.
UI Controlsfor Windows Forms
.NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI Design
WinForms UI Controls