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