728x90
728x90
SMALL

Winform 3

[C#] 사용자 정의 이벤트 등록 및 사용 예제

1. 이벤트 핸들러 선언 이벤트 핸들러 대리자를 전역으로 선언한다. 가급적이면 이벤트가 실제 발생하는 위치에 선언하는 것이 좋다. 2. 이벤트 등록 이벤트가 발생할 클래스 내부에 위에서 선언한 이벤트 핸들러 대리자로 이벤트 변수를 정의한다. 이벤트 += 이벤트처리함수3. 이벤트 해제이벤트를 해제한 후에는 이벤트가 발생해도 이벤트처리함수가 작동하지 않는다이벤트 -= 이벤트처리함수4. 사용 예제1) 이벤트가 실제 발생하는 곳using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Drawing; using Syst..

유용한 정보 2025.04.27

[C#] 임의의 컨트롤을 사용하여 폼을 이동하자

1. 소스/// /// WinForm에서 사용자가 정의한 타이틀바에 의해서 폼을 이동 한다. /// /// 폼 /// 사용자정의 타이틀바에 속해 있는 컨트롤목록 /// 마우스커서void SetMovingForm(this Form form, Control[] triggerControls, Cursor movingCursorOrNull = null) { bool mouseDown = false; Point lastMousePoint = new Point(); Cursor movingCursor; if (movingCursorOrNull == null) movingCursor = Cursors.NoMove2D; else movingCursor = movingCursorOrNull; Dictionary ol..

유용한 정보 2025.04.16

[C#] 윈폼과 콘솔창을 같이 사용하기 위한 콘솔창 할당하기

[System.Runtime.InteropServices.DllImport("kernel32.dll", SetLastError = true)][return: System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.Bool)]private static extern bool AllocConsole();  private void Frm_Main_Load(object sender, EventArgs e){... AllocConsole(); ...} 임의의 함수{... AddMessage("테스트"); ...}  private delegate void AddMessageDelegate(string msg);priva..

기본카테고리 2016.09.10
728x90
728x90
LIST