[C#/WINFORM] ParentControlDesigner 클래스를 사용해 디자이너 모드에서 편집 가능한 사용자 컨트롤 만들기
C#/WinForm 2019. 5. 8. 23:04728x90
728x170
▶ SampleControlDesigner.cs
using System.ComponentModel;
using System.Windows.Forms.Design;
namespace TestProject
{
/// <summary>
/// 샘플 컨트롤 디자이너
/// </summary>
public class SampleControlDesigner : ParentControlDesigner
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 초기화 하기 - Initialize(component)
/// <summary>
/// 초기화 하기
/// </summary>
/// <param name="component">컴포넌트</param>
public override void Initialize(IComponent component)
{
base.Initialize(component);
SampleControl sampleControl = component as SampleControl;
if(sampleControl != null)
{
base.EnableDesignMode(sampleControl.RootPanel, "RootPanel");
}
}
#endregion
}
}
▶ SampleControl.cs
using System.ComponentModel;
using System.Windows.Forms;
namespace TestProject
{
/// <summary>
/// 샘플 컨트롤
/// </summary>
[Designer(typeof(SampleControlDesigner))]
public partial class SampleControl : UserControl
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Field
////////////////////////////////////////////////////////////////////////////////////////// Public
#region Field
[Category("SampleControl"),Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public Panel RootPanel => this.rootPanel;
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - SampleControl()
/// <summary>
/// 생성자
/// </summary>
public SampleControl()
{
InitializeComponent();
}
#endregion
}
}
728x90
그리드형(광고전용)
'C# > WinForm' 카테고리의 다른 글
[C#/WINFORM] SynchronizationContext 클래스 : 크로스 스레드(Cross Thread) 처리하기 (0) | 2019.07.13 |
---|---|
[C#/WINFORM] 실시간 스트리밍 프로토콜(RTSP)을 사용해 동영상 재생하기 (0) | 2019.06.14 |
[C#/WINFORM] 웹 카메라 사용하기 (0) | 2019.06.12 |
[C#/WINFORM] A* (AStar) 길 찾기 알고리즘 사용하기 (0) | 2019.06.09 |
[C#/WINFORM] Screen 클래스 : AllScreens 정적 속성을 사용해 다른 모니터에서 폼 표시하기 (0) | 2019.05.25 |
[C#/WINFORM] ClickOnce 설치시 실행 권한이 없어서 설치가 안되는 경우 처리하기 (0) | 2019.01.16 |
[C#/WINFORM] 원(Oval) 이미지 구하기 (0) | 2019.01.15 |
[C#/WINFORM] 시어핀스키 8각형(Sierpinski Octagon) 그리기 (0) | 2019.01.15 |
[C#/WINFORM] 쌍곡나사선(Hyperbolic Spiral) 그리기 (0) | 2019.01.15 |
[C#/WINFORM] 아르키메데스 나선(Archimedes Spiral) 그리기 (0) | 2019.01.15 |