Some problems by drag and drop.

  • Thread starter Thread starter erik_wout
  • Start date Start date
E

erik_wout

When I compile the folowing:

using System;
using System.Windows.Forms;

namespace ECEG {
public class MainForm : Form
{
Label lFiles;

static int Main(){
System.Threading.Thread.CurrentThread.ApartmentState =
System.Threading.ApartmentState.STA;
MainForm mf = new MainForm();
Application.Run(mf);
return 0;
}
public MainForm()
{
Text = "Easy Copy, Easy GO!";
Height = 200;
Width = 300;
MinimizeBox = false;
MaximizeBox = false;
lFiles = new Label();
lFiles.Parent = this;
lFiles.Width = 120;
lFiles.Dock = DockStyle.Right;
lFiles.Text = "No Files...";
lFiles.BorderStyle = BorderStyle.FixedSingle;
lFiles.AllowDrop = true;
lFiles.DragOver += new DragEventHandler(NewFile);
lFiles.DragDrop += new DragEventHandler(FileNow);
}

void NewFile(object obj, DragEventArgs dea){
if (dea.Data.GetDataPresent(DataFormats.FileDrop)) {
if ((dea.AllowedEffect & DragDropEffects.Copy) != 0)
dea.effect = DragDropEffects.Copy; // Hier treed de fout
op!!!
}
}

void FileNow(object obj, DragEventArgs dea){
if (lFiles.Text == "No Files...") lFiles.Text = "";
foreach (string AddFile in (string[])
dea.Data.GetData(DataFormats.FileDrop))
lFiles.Text += AddFile + "\n";
}
}
}



I get the following error message:

"System.Windows.Forms.DragEventsArgs.effect is unaccesseble due to its
protection level (CS0122)"

Can Someone say why I get this and what I must do to make this work?
 
erik_wout said:
"System.Windows.Forms.DragEventsArgs.effect is
unaccesseble due to its protection level (CS0122)"

I think it should be DragEventArgs.Effect (with a capital E).

P.
 
Back
Top