MouseEventArgs.Button プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)


TextBox コントロールの MouseDown イベントを処理して、マウスの右ボタンをクリックするとコントロール内のすべてのテキストが選択されるようにするコード例を次に示します。この例では、textBox1 という名前の TextBox コントロールがフォームに配置されている必要があります。
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load TextBox1.ContextMenu = New ContextMenu() End Sub Private Sub TextBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseDown If (e.Button = Windows.Forms.MouseButtons.Right) Then TextBox1.Select(0, TextBox1.Text.Length) End If End Sub
private void Form1_Load(object sender, EventArgs e) { // This line suppresses the default context menu for the TextBox control. textBox1.ContextMenu = new ContextMenu(); textBox1.MouseDown += new MouseEventHandler(textBox1_MouseDown); } void textBox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button == MouseButtons.Right) { textBox1.Select(0, textBox1.Text.Length); } }

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からMouseEventArgs.Button プロパティを検索する場合は、下記のリンクをクリックしてください。

- MouseEventArgs.Button プロパティのページへのリンク