ToolStrip.BeginDrag 이벤트
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
사용자가 ToolStrip 컨트롤을 끌기 시작하면 발생합니다.
public:
event EventHandler ^ BeginDrag;
public event EventHandler BeginDrag;
public event EventHandler? BeginDrag;
member this.BeginDrag : EventHandler
Public Custom Event BeginDrag As EventHandler
이벤트 유형
예제
다음 코드 예제를 사용 하 여 BeginDrag 및 EndDragToolStrip 및 합니다 ToolStripContainer.
using System;
using System.Windows.Forms;
public class Form1 : Form
{
private ToolStripContainer toolStripContainer1;
private ToolStrip toolStrip1;
private RichTextBox richTextBox1;
public Form1()
{
DragToolStrip();
}
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.Run(new Form1());
}
private void DragToolStrip()
{
// Create a ToolStripContainer.
toolStripContainer1 = new System.Windows.Forms.ToolStripContainer();
toolStripContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
Controls.Add(toolStripContainer1);
// Create a ToolStrip and add items to it.
toolStrip1 = new System.Windows.Forms.ToolStrip();
toolStrip1.Items.Add("One");
toolStrip1.Items.Add("Two");
toolStrip1.Items.Add("Three");
// Add the ToolStrip to the top panel of the ToolStripContainer.
toolStripContainer1.TopToolStripPanel.Controls.Add(toolStrip1);
// Create a RichTextBox and add it to the ContentPanel.
richTextBox1 = new System.Windows.Forms.RichTextBox();
richTextBox1.Location = new System.Drawing.Point(94, 61);
toolStripContainer1.ContentPanel.Controls.Add(richTextBox1);
// Attach event handlers for the BeginDrag and EndDrag events.
toolStrip1.BeginDrag += new System.EventHandler(toolStrip1_BeginDrag);
toolStrip1.EndDrag += new System.EventHandler(toolStrip1_EndDrag);
}
// Clear any text from the RichTextBox when a drag operation begins.
private void toolStrip1_BeginDrag(object sender, EventArgs e)
{
richTextBox1.Text = "";
}
// Notify the user when the drag operation ends.
private void toolStrip1_EndDrag(object sender, EventArgs e)
{
richTextBox1.Text="The drag operation is complete.";
}
}
Imports System.Windows.Forms
Public Class Form1
Inherits Form
Private toolStripContainer1 As ToolStripContainer
Private toolStrip1 As ToolStrip
Private richTextBox1 As RichTextBox
Public Sub New()
DragToolStrip()
End Sub
<STAThread()> _
Shared Sub Main()
Application.EnableVisualStyles()
Application.Run(New Form1())
End Sub
Private Sub DragToolStrip()
' Create a ToolStripContainer.
toolStripContainer1 = New System.Windows.Forms.ToolStripContainer()
toolStripContainer1.Dock = System.Windows.Forms.DockStyle.Fill
Controls.Add(toolStripContainer1)
' Create a ToolStrip and add items to it.
toolStrip1 = New System.Windows.Forms.ToolStrip()
toolStrip1.Items.Add("One")
toolStrip1.Items.Add("Two")
toolStrip1.Items.Add("Three")
' Add the ToolStrip to the top panel of the ToolStripContainer.
toolStripContainer1.TopToolStripPanel.Controls.Add(toolStrip1)
' Create a RichTextBox and add it to the ContentPanel.
richTextBox1 = New System.Windows.Forms.RichTextBox()
richTextBox1.Location = New System.Drawing.Point(94, 61)
toolStripContainer1.ContentPanel.Controls.Add(richTextBox1)
' Attach event handlers for the BeginDrag and EndDrag events.
AddHandler toolStrip1.BeginDrag, AddressOf toolStrip1_BeginDrag
AddHandler toolStrip1.EndDrag, AddressOf toolStrip1_EndDrag
End Sub
' Clear any text from the RichTextBox when a drag operation begins.
Private Sub toolStrip1_BeginDrag(sender As Object, e As EventArgs)
richTextBox1.Text = ""
End Sub
' Notify the user when the drag operation ends.
Private Sub toolStrip1_EndDrag(sender As Object, e As EventArgs)
richTextBox1.Text = "The drag operation is complete."
End Sub
End Class
설명
이벤트 처리에 대한 자세한 내용은 이벤트 처리 및 발생 을 참조하십시오.
적용 대상
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET