RichTextBox.DragDrop 事件 [C#]该成员支持 .NET Framework 结构,因此不适用于直接从代码中使用。[C#]
public new event DragEventHandler DragDrop;
public new event DragEventHandler DragDrop;
解决方案 »
- .net C#爱普生打印机利用code128字体打印条形码时怎么选择code128字体
- sqlserver2000分批取数
- 【问题】关于winform获取光标所在控件
- 奇怪的 Socket
- |zyciis| 200分求 在VS2003 WinFrom 中的 DataGrid 如何给他添加汇总 如何手动调节列的宽度
- 类似VS的功能,如何实现啊?
- 关于winform系统中数据库连接串的安全问题,困惑我很久了
- 如何获得远程机器的目录?请高手进入,问题解决,马上给分。
- 如何在控件上绘图
- SqlConnection关闭后的释放问题
- C++ TO C#
- 用c#编写的WINDOWS应用程序如何编译成本地代码?
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Sets the AllowDrop property so that data can be dragged onto the control.
RichTextBox1.AllowDrop = True ' Add code here to populate the ListBox1 with paths to text files.End SubPrivate Sub RichTextBox1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles RichTextBox1.DragEnter
' If the data is text, copy the data to the RichTextBox control.
If (e.Data.GetDataPresent("Text")) Then
e.Effect = DragDropEffects.Copy
End If
End Sub
Private Overloads Sub RichTextBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles RichTextBox1.DragDrop
' Loads the file into the control.
RichTextBox1.LoadFile(e.Data.GetData("Text"), System.Windows.Forms.RichTextBoxStreamType.RichText)
End SubPrivate Sub ListBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDown
Dim Lb As ListBox
Dim Pt As New Point(e.X, e.Y)
Dim Index As Integer ' Determines which item was selected.
Lb = sender
Index = Lb.IndexFromPoint(Pt) ' Starts a drag-and-drop operation with that item.
If Index >= 0 Then
Lb.DoDragDrop(Lb.Items(Index), DragDropEffects.Link)
End If
End Sub[C#]
private void Form1_Load(object sender, EventArgs e)
{
// Sets the AllowDrop property so that data can be dragged onto the control.
richTextBox1.AllowDrop = true; // Add code here to populate the ListBox1 with paths to text files.}private void listBox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
// Determines which item was selected.
ListBox lb =( (ListBox)sender);
Point pt = new Point(e.X,e.Y);
int index = lb.IndexFromPoint(pt); // Starts a drag-and-drop operation with that item.
if(index>=0)
{
lb.DoDragDrop(lb.Items[index].ToString(), DragDropEffects.Link);
}
}private void richTextBox1_DragEnter(object sender, DragEventArgs e)
{
// If the data is text, copy the data to the RichTextBox control.
if(e.Data.GetDataPresent("Text"))
e.Effect = DragDropEffects.Copy;
}private void richTextBox1_DragDrop(object sender, DragEventArgs e)
{
// Loads the file into the control.
richTextBox1.LoadFile((String)e.Data.GetData("Text"), System.Windows.Forms.RichTextBoxStreamType.RichText);
}