티스토리 뷰
반응형
PointToClient는 커서의 위치를 어플리케이션의 위치로 계산해주는 매소드이다. 반대로 PointToScreen매소드는 어플리케이션의 위치를 모니터 스크린의 좌표값으로 계산해준다. 예제) TreeView에서 마우스로 클릭된 노드의 아이템 가져오기 TreeNode tree = null;
private void treeView1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { tree = treeView1.GetNodeAt(e.X, e.Y); // 좌표가 안나올대 PointToClient를 사용하여 좌표값을 알아올 수 있다 //tree = treeView1.GetNodeAt(treeView1.PointToClient(Cursor.Position).X, treeView1.PointToClient(Cursor.Position).Y); } } |
반응형
댓글