Open voidZiAD opened 2 years ago
Greetings,
Hope this helps someone out.
private void SqlCmdWindow_DragOver(object sender, DragEventArgs e) { // Check if the format of the data can be accepted // Only accept file drops from Explorer, etc. var ccx = StringComparison.InvariantCultureIgnoreCase; string[] files = (string[])e.Data.GetData(DataFormats.FileDrop, false); var filePath = files.FirstOrDefault();
if (filePath != null && (filePath.EndsWith(".sql", ccx) || filePath.EndsWith(".txt", ccx)))
e.Effect = DragDropEffects.Link;
else
e.Effect = DragDropEffects.None;
}
private void SqlCmdWindow_DragDrop(object sender, DragEventArgs e) { // Extract the data from the DataObject-Container into a string list var ccx = StringComparison.InvariantCultureIgnoreCase; string[] files = (string[])e.Data.GetData(DataFormats.FileDrop, false); var filePath = files.FirstOrDefault();
if (filePath != null && (filePath.EndsWith(".sql", ccx) || filePath.EndsWith(".txt", ccx)))
{
TitleMsg.Text = filePath;
var fileText = File.ReadAllText(filePath);
// Add file text into FastColoredTextBox control:
SqlCmdWindow.Text = fileText;
}
}
Hope this helps : )
When using FastColoredTextbox, I'm not able to make the DragDrop or DragEnter or DragOver events work. Basically, when I put in some code inside the Events nothing changes, I've looked all over the internet to try making drag and drop work however it still does not.
Any solutions or any way this can be fixed for FastColoredTextbox?