Support
Joined: 18 Jul 2005 Posts: 731
|
Posted: Tue Aug 26, 2008 6:03 am Post subject: HOWTO: Retrieve selected items in Windows Explorer or a File Open/Save dialog |
|
|
Use the GetSelectedItems method in the OnSelectionChanged method to retrieve the list of selected items in Windows Explorer or a File Open/Save dialog.
This can be used in combination with the OnCommonDialogOKButtonClicked method to determine the item(s) selected in the File Open/Save dialog when the 'OK' button is clicked (or when item is double-clicked or when item is selected and 'Enter' is pressed) :
[C#]
class MyNSEFolder : NSEFolder
{
...
...
NSEItem[] selectedItems = null;
public override void OnSelectionChanged()
{
selectedItems = this.GetSelectedItems(); // Store selected items
}
public override void OnCommonDialogOKButtonClicked(CommonDialogOKButtonClickedEventArgs e)
{
// 'selectedItems' array now contains user-selected item(s)
foreach (NSEItem item in selectedItems)
{
System.Diagnostics.Debug.WriteLine(item.ToString());
}
}
...
...
}
[VB.Net]
Public Class MyNSEFolder
Inherits NSEFolder
...
...
Dim selectedItems As NSEItem() = Nothing
Public Overrides Sub OnSelectionChanged()
selectedItems = Me.GetSelectedItems() ' Store selected items
End Sub
Public Overrides Sub OnCommonDialogOKButtonClicked(ByVal e As CommonDialogOKButtonClickedEventArgs)
'selectedItems array now contains user-selected item(s)
Dim item As NSEItem
For Each item In selectedItems
System.Diagnostics.Debug.WriteLine(item.ToString())
Next
End Sub
...
...
End Class |
|