게시물을 THIS으로 읽어보십시오. 이 게시물에 설명 된 것과 동일한 문제가 있지만 VB.net 대신 C#으로 작업하려고합니다.vb.net winforms 사용자 정의 컨트롤에 대한 사용자 지정 이벤트를 표시하고 발생시키는 방법
나는 사용자 지정 이벤트를 사용해야한다는 것을 확신합니다. (. 나는 사용자 정의 이벤트에 대해 배우고 얻을 수있는 code conversion site을 사용) 그래서 IDE에서 나는 다음 입력 할 때 : 그것은 다음과 같은 코드로 확장
이벤트 핸들러
으로공공 사용자 정의 이벤트 AddRemoveAttendees.
Public Custom Event AddRemoveAttendees As EventHandler
AddHandler(ByVal value As EventHandler)
End AddHandler
RemoveHandler(ByVal value As EventHandler)
End RemoveHandler
RaiseEvent(ByVal sender As Object, ByVal e As System.EventArgs)
End RaiseEvent
End Event
하지만 어떻게해야할지 모르겠다. 오늘까지는 맞춤 이벤트에 대해 들어 본 적이 없었습니다.
내가 원하는 것은 사용자 컨트롤의 컨테이너까지 버튼 버블의 클릭 이벤트를 갖는 것입니다. 나는 내 자신의 이벤트를 감쌀 수 있다는 것을 알고 있지만 적어도 내가 길을 떠나기 전에 맞춤 이벤트를 이해하고 싶습니다. 당신은 단순히 첨부하거나 지정된 이벤트를 제거하기 위해 전화를 전파 RemoveHandler
AddHandler
에서
Public Custom Event AddRemoveAttendees As EventHandler
AddHandler(ByVal value As EventHandler)
AddHandler _theButton.Click, value
End AddHandler
RemoveHandler(ByVal value As EventHandler)
RemoveHandler _theButton.Click, value
End RemoveHandler
RaiseEvent(ByVal sender As Object, ByVal e As System.EventArgs)
' no need to do anything in here since you will actually '
' not raise this event; it only acts as a "placeholder" for the '
' buttons click event '
End RaiseEvent
End Event
과 :
세스
감사를 자신의 이벤트를 발생 ... 내가 준 fi에 대답 플래그 첫 번째 게시물은 철저하지만 귀하의 답변을 upvoted. 사용자 정의 컨트롤이 사용자의 제안에 따라 chilc 컨트롤 대신 이벤트를 방출 할 수 있도록 컨트롤을 표준 대리자 및 컨트롤의 이벤트로 래핑하기로 결정했습니다. 감사. 세스 –