Skip to content

Commit 0cc48a8

Browse files
committed
Imlemented drag and drop for SSMS objects
1 parent f73353a commit 0cc48a8

File tree

2 files changed

+43
-12
lines changed

2 files changed

+43
-12
lines changed

Code/TSqlFlex/FlexMainWindow.Designer.cs

Lines changed: 15 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Code/TSqlFlex/FlexMainWindow.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.ComponentModel;
33
using System.Data.SqlClient;
44
using System.Diagnostics;
5+
using System.Drawing;
56
using System.IO;
67
using System.Runtime.InteropServices;
78
using System.Text;
@@ -389,5 +390,32 @@ private void btnExcel_Click(object sender, EventArgs e)
389390
MessageBox.Show(Excel.ExcelError, "T-SQL Flex couldn't launch Excel");
390391
}
391392
}
393+
394+
private void txtSqlInput_DragDrop(object sender, DragEventArgs e)
395+
{
396+
try
397+
{
398+
string theObjectName = e.Data.GetData(DataFormats.Text).ToString();
399+
Point pointOnTextbox = txtSqlInput.PointToClient(new Point(e.X, e.Y));
400+
int charIndex = txtSqlInput.GetCharIndexFromPosition(pointOnTextbox);
401+
txtSqlInput.Text = txtSqlInput.Text.Insert(charIndex, FieldScripting.EscapeObjectNames(theObjectName));
402+
}
403+
catch (Exception ex)
404+
{
405+
MessageBox.Show("Could not drag and drop.\r\n\r\n" + ex.Message, "T-SQL Flex");
406+
}
407+
}
408+
409+
private void txtSqlInput_DragEnter(object sender, DragEventArgs e)
410+
{
411+
if (e.Data.GetDataPresent(DataFormats.Text))
412+
{
413+
e.Effect = DragDropEffects.Copy;
414+
}
415+
else
416+
{
417+
e.Effect = DragDropEffects.None;
418+
}
419+
}
392420
}
393421
}

0 commit comments

Comments
 (0)