2009-10-15 4 views

답변

1

Button 클래스에서 상속 한 사용자 정의 컨트롤을 만든 다음 OnPaint() 메서드를 재정의합니다.

사용자 정의 컨트롤을 상속 한 후에는 컨트롤의 부분 클래스에서 수정이 필요하다는 메시지가 표시되고 IDE의 제안을 사용하여 수정하고 (현재) 사용되지 않는 AutoScaleMode 속성을 디자이너 코드 (생성자에서).

편집 : 틀렸어. OnPaint() 메서드를 재정의하고 텍스트를 포함하여 단추를 완전히 그려야합니다.

Public Class myButton : Inherits System.Windows.Forms.Button 
Protected Overrides Sub OnPaint(ByVal pevent As System.Windows.Forms.PaintEventArgs) 
    'MyBase.OnPaint(pevent) 
    pevent.Graphics.DrawImage(myimage, 0, 0, myimage.Width, myimage.Height) 
    pevent.Graphics.DrawString(Me.Text, Me.Font, SystemBrushes.GrayText, 0, 0) 
End Sub 
End Class 
관련 문제