Version

ItemExitedEditMode Event

Occurs after an UltraListViewItem has exited edit mode.
Syntax
'Declaration
 
Public Event ItemExitedEditMode As ItemExitedEditModeEventHandler
public event ItemExitedEditModeEventHandler ItemExitedEditMode
Event Data

The event handler receives an argument of type ItemExitedEditModeEventArgs containing data related to this event. The following ItemExitedEditModeEventArgs properties provide information specific to this event.

PropertyDescription
Item (Inherited from Infragistics.Win.UltraWinListView.ItemEventArgs)Returns the UltraListViewItem with which this instance is associated.
Example
The following code sample demonstrates how to handle the UltraListView control's edit mode events to conditionally prevent an edit mode session from beginning or ending, as well as perform a specific action after edit mode is entered or exited:

For an overview of how to handle events in Visual Basic or Visual C#, see Event Handlers in Visual Basic and Visual C#. For specific information and code examples illustrating how to consume events in your application, see Consuming Events in the .NET Framework Developer's Guide.

Imports Infragistics.Win
Imports Infragistics.Win.UltraWinListView

    Private Sub ultraListView1_ItemEnteringEditMode(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinListView.ItemEnteringEditModeEventArgs) Handles ultraListView1.ItemEnteringEditMode

        '	If the item represents a DataRow that has been deleted,
        '	cancel the event to prevent edit mode from being entered.
        If e.Item.Tag.GetType() Is GetType(DataRow) Then

            Dim dataRow As DataRow = CType(e.Item.Tag, DataRow)
            If (dataRow.RowState = DataRowState.Deleted) Then
                e.Cancel = True
            End If
        End If

    End Sub

    Private Sub ultraListView1_ItemEnteredEditMode(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinListView.ItemEnteredEditModeEventArgs) Handles ultraListView1.ItemEnteredEditMode

        '	If the embeddable editor for this item supports a dropdown,
        '	call the DropDown method.
        Dim embeddableElement As EmbeddableUIElementBase = e.Item.UIElement.GetDescendant(GetType(EmbeddableUIElementBase), e.Item)
        Dim editor As EmbeddableEditorBase = IIf(Not embeddableElement Is Nothing, embeddableElement.Editor, Nothing)

        If (Not editor Is Nothing AndAlso editor.SupportsDropDown) Then
            editor.DropDown()
        End If

    End Sub

    Private Sub ultraListView1_ItemExitingEditMode(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinListView.ItemExitingEditModeEventArgs) Handles ultraListView1.ItemExitingEditMode

        '	If changes are to be applied, and the item that was edited
        '	represents a FileInfo object, make sure that the file does
        '	not exist - if it does, cancel the event and display a message.
        If e.ApplyChanges Then

            If e.Item.Tag.GetType() Is GetType(System.IO.FileInfo) Then

                Dim fileInfo As System.IO.FileInfo = CType(e.Item.Tag, System.IO.FileInfo)
                Dim newFileName As String = String.Format("{0}\{1}", fileInfo.DirectoryName, e.Editor.CurrentEditText)
                If System.IO.File.Exists(newFileName) Then

                    Dim message As String = String.Format("Cannot rename {0}: A file with the name you specified already exists. Specify a different file name.", e.Editor.CurrentEditText)
                    MessageBox.Show(message, "Error Renaming File or Folder", MessageBoxButtons.OK, MessageBoxIcon.Error)
                    e.Cancel = True

                End If
            End If
        End If

    End Sub

    Private Sub ultraListView1_ItemExitedEditMode(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinListView.ItemExitedEditModeEventArgs) Handles ultraListView1.ItemExitedEditMode

        '	If the item that was edited represents a FileInfo object,
        '	refresh the file system object information.
        If e.Item.Tag.GetType() Is GetType(System.IO.FileInfo) Then

            Dim fileInfo As System.IO.FileInfo = CType(e.Item.Tag, System.IO.FileInfo)
            Me.RefreshFileSystemObject(e.Item)
        End If
    End Sub
using Infragistics.Win;
using Infragistics.Win.UltraWinListView;
using System.Diagnostics;

		private void ultraListView1_ItemEnteringEditMode(object sender, Infragistics.Win.UltraWinListView.ItemEnteringEditModeEventArgs e)
		{
			//	If the item represents a DataRow that has been deleted,
			//	cancel the event to prevent edit mode from being entered.
			if ( e.Item.Tag is DataRow )
			{
				DataRow dataRow = e.Item.Tag as DataRow;
				if ( dataRow.RowState == DataRowState.Deleted )
					e.Cancel = true;
			}
		}

		private void ultraListView1_ItemEnteredEditMode(object sender, Infragistics.Win.UltraWinListView.ItemEnteredEditModeEventArgs e)
		{
			//	If the embeddable editor for this item supports a dropdown,
			//	call the DropDown method.
			EmbeddableUIElementBase embeddableElement = e.Item.UIElement.GetDescendant( typeof(EmbeddableUIElementBase), e.Item ) as EmbeddableUIElementBase;
			EmbeddableEditorBase editor = embeddableElement != null ? embeddableElement.Editor : null;
			
			if ( editor != null && editor.SupportsDropDown )
				editor.DropDown();
		}

		private void ultraListView1_ItemExitingEditMode(object sender, Infragistics.Win.UltraWinListView.ItemExitingEditModeEventArgs e)
		{
			//	If changes are to be applied, and the item that was edited
			//	represents a FileInfo object, make sure that the file does
			//	not exist; if it does, cancel the event and display a message.
			if ( e.ApplyChanges )
			{
				if ( e.Item.Tag is System.IO.FileInfo )
				{
					System.IO.FileInfo fileInfo = e.Item.Tag as System.IO.FileInfo;
					string newFileName = string.Format( @"{0}\{1}", fileInfo.DirectoryName, e.Editor.CurrentEditText );
					if ( System.IO.File.Exists(newFileName) )
					{
						string message = string.Format( "Cannot rename {0}: A file with the name you specified already exists. Specify a different file name.", e.Editor.CurrentEditText );
						MessageBox.Show( message, "Error Renaming File or Folder", MessageBoxButtons.OK, MessageBoxIcon.Error );
						e.Cancel = true;
					}
				}
			}
		}

		private void ultraListView1_ItemExitedEditMode(object sender, Infragistics.Win.UltraWinListView.ItemExitedEditModeEventArgs e)
		{
			//	If the item that was edited represents a FileInfo object,
			//	refresh the file system object information.
			if ( e.Item.Tag is System.IO.FileInfo )
			{
				System.IO.FileInfo fileInfo = e.Item.Tag as System.IO.FileInfo;
				this.RefreshFileSystemObject( e.Item );
			}
		}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also