I want the background of MainForm to change while dropping file from desktop to a Form. Photo of form, where I want to change BG Here is the code of drag and drop functionality.
private void ThisForm_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
e.Effect = DragDropEffects.All;
}
else
e.Effect = DragDropEffects.None;
}
private void ThisForm_DragDrop(object sender, DragEventArgs e)
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
if (files != null && files.Length != 0)
{
if (Path.GetExtension(files[0]) == ".pdf")
{
TextBoxSelectPdf.Text = files[0];
}
else
{
MessageBox.Show("Galimas tik PDF formatas");
}
}
}
My question - how to change background color while dropping file.
As per your last comment, it seems you are having some problem with the BackgroundColour property of your form.
You can set the BackgroundColour of your form anytime by using :
this.Backcolor = Color.Red;
As soon as you type a dot after Color, you will get a dropdown suggesting available colours(maybe only for Visual Studio). Then, you can set the desired colour.
Even if you don't get the dropdown, colours like Red, Blue, Black, White, etc. are always available.
Don't leave this part! :)
If you want to change the BackgroundColour when you drag something in, then add the above mentioned line in the DragEnter event after this e.Effect = DragDropEffects.None;
on a new line.