Sky Software Homepage LogicNP Software Knowledge Base And FAQ

 
Contact Product Support    SearchSearch      Subscribe to the RSS feed for this forum

HOWTO: Prevent certain files from being dropped in FolderView

 
Subscribe to the RSS feed for this forum  Forum Index -> FolderView.Net/WPF
View previous topic :: View next topic  
Author Message
Support



Joined: 18 Jul 2005
Posts: 731

Posted: Sat Apr 25, 2009 8:42 am    Post subject: HOWTO: Prevent certain files from being dropped in FolderView

To prevent certain files from being dropped in FolderView, use the following code in the FolderViewDragOver event:
[C#]
Code:
private void fldrView_FolderViewDragOver(object sender, FolderViewDragOverEventArgs e)
{
  // exit if no data
  if (e.Data == null)
      return;

  // retrieve files being dragged
  string[] draggedFiles = (String[])e.Data.GetData(DataFormats.FileDrop);

  // get first file in array
  string firstfile = draggedFiles[0];

  // convert to lowercase for comparison
  firstfile = firstfile.ToLower();

  // if files is from "c:\" drive, dont allow it to be dropped
  if (firstfile.IndexOf("c:\\") != -1)
      e.Effects = DragDropEffects.None;
}

[VB.Net]
Code:
Private Sub fldrView_FolderViewDragOver(ByVal sender As System.Object, ByVal e As LogicNP.FolderViewControl.FolderViewDragOverEventArgs) Handles fldrView.FolderViewDragOver
  ' exit if no data
  If (e.Data Is Nothing = True) Then
      Return
  End If

  ' retrieve files being dragged
  Dim draggedFiles As String() = CType(e.Data.GetData(DataFormats.FileDrop), String())

  ' get first file in array
  Dim firstfile As String = draggedFiles(0)

  ' convert to lowercase for comparison
  firstfile = firstfile.ToLower()

  ' if files is from "c:\" drive, dont allow it to be dropped
  If (firstfile.IndexOf("c:\") <> -1) Then
      e.Effects = DragDropEffects.None
  End If

End Sub
Back to top
Display posts from previous:   
Forum Index -> FolderView.Net/WPF All times are GMT
Page 1 of 1

 
Jump to:  


Powered by phpBB © 2001, 2005 phpBB Group