Export (0) Print
Expand All

ListView.AfterLabelEdit Event

Occurs when the label for an item is edited by the user.

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

member AfterLabelEdit : IEvent<LabelEditEventHandler,
    LabelEditEventArgs>

The AfterLabelEdit event occurs when the user finishes modifying the text for an item. The new string that the user types for the item is passed to the event, and the event handler can reject the change. If the event handler rejects the change, the text reverts to the text as it was before the user began editing the item.

NoteNote

Because the ListView.AfterLabelEdit event takes place before the label edit is committed, calling the ListView.Sort method in a handler for this event will sort the item using the original value.

In order for the AfterLabelEdit event to be raised, the LabelEdit property of the ListView control must be set to true.

You can create an event handler for the BeforeLabelEdit event to perform tasks before the user edits the text of an item.

For more information about handling events, see Consuming Events.

The following code example demonstrates how to use the AfterLabelEdit event to restrict a newly edited label to characters in the alphabet. The example uses the ASCIIEncoding class to obtain the ASCII character code of each character of the new label. If the character falls between the ASCII codes that represent numbers, the new label cannot be applied to the item. This example requires that you have created a ListView control on a form and added items to it. The example also requires that you have connected the AfterLabelEdit event to the event handler defined in the example code. In order to use the ASCIIEncoding class, your file must include the System.Text namespace.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2014 Microsoft