Control.MousePosition プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > Control.MousePosition プロパティの意味・解説 

Control.MousePosition プロパティ

マウス カーソル位置画面座標取得します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Shared ReadOnly Property
 MousePosition As Point
Dim value As Point

value = Control.MousePosition
public static Point MousePosition { get;
 }
public:
static property Point MousePosition {
    Point get ();
}
/** @property */
public static Point get_MousePosition ()

プロパティ
画面左上隅に対す相対座標として、マウス カーソル座標格納している Point

解説解説
使用例使用例

マウス カーソルツリー ノードの上にあるときにユーザーAlt キー押しながら E キー押した場合に、TreeNode ラベル編集できる状態にするコード例次に示しますラベル編集完了したら、再度 Alt キーと E キー同時に押されるまでそのラベル編集できません。この例では、TreeView が Form 上に存在している必要がありますまた、ツリー ビューには、Nodes コレクション内に少なくとも 1 つTreeNode が必要です。

Private Sub treeView1_KeyDown(sender As
 Object, _
  e As KeyEventArgs) Handles treeView1.KeyDown
   ' If the 'Alt' and 'E' keys are pressed,
   ' allow the user to edit the TreeNode label. 
   If e.Alt And e.KeyCode = Keys.E Then
      treeView1.LabelEdit = True
      ' If there is a TreeNode under the mose cursor, begin editing.
 
      Dim editNode As TreeNode = treeView1.GetNodeAt(
 _
        treeView1.PointToClient(Control.MousePosition))
      If Not (editNode Is
 Nothing) Then
         editNode.BeginEdit()
      End If
   End If
End Sub

Private Sub treeView1_AfterLabelEdit(sender
 As Object, _
  e As NodeLabelEditEventArgs) Handles treeView1.AfterLabelEdit
   ' Disable the ability to edit the TreeNode labels.
   treeView1.LabelEdit = False
End Sub
private void treeView1_KeyDown(object sender,
 KeyEventArgs e)
{
   /* If the 'Alt' and 'E' keys are pressed,
      * allow the user to edit the TreeNode label. */
   if(e.Alt && e.KeyCode == Keys.E)
         
   {
      treeView1.LabelEdit = true;
      // If there is a TreeNode under the mose cursor, begin editing.
 
      TreeNode editNode = treeView1.GetNodeAt(
         treeView1.PointToClient(Control.MousePosition));
      if(editNode != null)
      { 
         editNode.BeginEdit();
      }
   }
}

private void treeView1_AfterLabelEdit(object
 sender, NodeLabelEditEventArgs e)
{
   // Disable the ability to edit the TreeNode labels.
   treeView1.LabelEdit = false;
}
private:
   void treeView1_KeyDown( Object^ /*sender*/, KeyEventArgs^ e
 )
   {
      /* If the 'Alt' and 'E' keys are pressed,
         * allow the user to edit the TreeNode label. */
      if ( e->Alt && e->KeyCode == Keys::E )
      {
         treeView1->LabelEdit = true;
         
         // If there is a TreeNode under the mose cursor, begin editing.
         TreeNode^ editNode = treeView1->GetNodeAt( treeView1->PointToClient(
 Control::MousePosition ) );
         if ( editNode != nullptr )
         {
            editNode->BeginEdit();
         }
      }
   }

   void treeView1_AfterLabelEdit( Object^ /*sender*/, NodeLabelEditEventArgs^
 /*e*/ )
   {
      // Disable the ability to edit the TreeNode labels.
      treeView1->LabelEdit = false;
   }
private void treeView1_KeyDown(Object sender,
 KeyEventArgs e)
{
    /* If the 'Alt' and 'E' keys are pressed,
       allow the user to edit the TreeNode label. 
     */
    if (e.get_Alt() && e.get_KeyCode() == Keys.E) {
        treeView1.set_LabelEdit(true);
        // If there is a TreeNode under the mose cursor, begin editing.
 
        TreeNode editNode = treeView1.GetNodeAt(treeView1.PointToClient(
            Control.get_MousePosition()));
        if (editNode != null) {
            editNode.BeginEdit();
        }
    }
} //treeView1_KeyDown

private void treeView1_AfterLabelEdit(Object
 sender, 
    NodeLabelEditEventArgs e)
{
    // Disable the ability to edit the TreeNode labels.
    treeView1.set_LabelEdit(false);
} //treeView1_AfterLabelEdit
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からControl.MousePosition プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からControl.MousePosition プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からControl.MousePosition プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Control.MousePosition プロパティ」の関連用語

Control.MousePosition プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Control.MousePosition プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS