728x90
반응형
728x170
▶ Customer.cs
using System;
using System.ComponentModel;
using System.Drawing;
namespace TestProject
{
/// <summary>
/// 고객
/// </summary>
public class Customer
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Property
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 성명 - Name
/// <summary>
/// 성명
/// </summary>
[Category("ID 설정")]
[Description("고객명")]
public string Name { get; set; }
#endregion
#region 나이 - Age
/// <summary>
/// 나이
/// </summary>
[Category("ID 설정")]
[Description("나이")]
public int Age { get; set; }
#endregion
#region 생일 - Birthday
/// <summary>
/// 생일
/// </summary>
[Category("ID 설정")]
[Description("생일")]
public DateTime Birthday { get; set; }
#endregion
#region 주민등록번호 - SSN
/// <summary>
/// 주민등록번호
/// </summary>
[Category("ID 설정")]
[Description("주민등록번호")]
public string SSN { get; set; }
#endregion
#region 주소 - Address
/// <summary>
/// 주소
/// </summary>
[Category("ID 설정")]
[Description("주소")]
[TypeConverter(typeof(AddressConverter))]
public string Address { get; set; }
#endregion
#region E 메일 주소 - EMailAddress
/// <summary>
/// E 메일 주소
/// </summary>
[Category("마케팅 설정")]
[Description("E 메일 주소")]
public string EMailAddress { get; set; }
#endregion
#region 단골 고객 여부 - IsFrequentBuyer
/// <summary>
/// 단골 고객 여부
/// </summary>
[Category("마케팅 설정")]
[Description("단골 고객 여부")]
public bool IsFrequentBuyer { get; set; }
#endregion
#region 테스트 색상 - TestColor
/// <summary>
/// 테스트 색상
/// </summary>
[Category("ID 설정")]
[Description("테스트 색상")]
public Color TestColor { get; set; }
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - Customer
/// <summary>
/// 생성자
/// </summary>
public Customer()
{
}
#endregion
}
}
728x90
▶ AddressConverter.cs
using System.ComponentModel;
namespace TestProject
{
/// <summary>
/// 주소 변환자
/// </summary>
public class AddressConverter : StringConverter
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Field
////////////////////////////////////////////////////////////////////////////////////////// Private
#region Field
/// <summary>
/// 주소 배열
/// </summary>
private string[] addressArray = new string[]
{
"서울시 강남구",
"서울시 관악구",
"서울시 중구"
};
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 표준 값 지원 여부 구하기 - GetStandardValuesSupported(context)
/// <summary>
/// 표준 값 지원 여부 구하기
/// </summary>
/// <param name="context">컨텍스트</param>
/// <returns>표준 값 지원 여부</returns>
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
{
return true;
}
#endregion
#region 표준 값 단독 여부 구하기 - GetStandardValuesExclusive(context)
/// <summary>
/// 표준 값 단독 여부 구하기
/// </summary>
/// <param name="context">컨텍스트</param>
/// <returns>표준 값 단독 여부</returns>
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
{
return true;
}
#endregion
#region 표준 값 구하기 - GetStandardValues(context)
/// <summary>
/// 표준 값 구하기
/// </summary>
/// <param name="context">컨텍스트</param>
/// <returns>표준 값</returns>
public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
return new StandardValuesCollection(this.addressArray);
}
#endregion
}
}
300x250
▶ MainForm.cs
using System;
using System.Drawing;
using System.Windows.Forms;
namespace TestProject
{
/// <summary>
/// 메인 폼
/// </summary>
public partial class MainForm : Form
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainForm()
/// <summary>
/// 생성자
/// </summary>
public MainForm()
{
InitializeComponent();
this.setButton.Click += setButton_Click;
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Private
//////////////////////////////////////////////////////////////////////////////// Event
#region 설정 버튼 클릭시 처리하기 - setButton_Click(sender, e)
/// <summary>
/// 설정 버튼 클릭시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void setButton_Click(object sender, EventArgs e)
{
Customer customer = new Customer();
customer.Name = "홍길동";
customer.Age = 18;
customer.Birthday = new DateTime(2000, 1, 1);
customer.SSN = "000101-3234567";
customer.Address = "서울시 관악구";
customer.EMailAddress = "test@daum.com";
customer.TestColor = Color.Red;
propertyGrid.SelectedObject = customer;
}
#endregion
}
}
728x90
반응형
그리드형(광고전용)
'C# > WinForm' 카테고리의 다른 글
[C#/WINFORM] DirectShow를 사용해 동영상 재생하기 (0) | 2018.04.02 |
---|---|
[C#/WINFORM] 설치 프린터 조회하기 (0) | 2018.03.22 |
[C#/WINFORM] 윈폼(WinForm)에서 콘솔(Console) 사용하기 (0) | 2018.03.22 |
[C#/WINFORM] BitBlt 함수를 사용해 비트맵 복사하기 (0) | 2018.03.15 |
[C#/WINFORM] PropertyGrid 클래스 : 이미지 목록을 사용해 항목 값 선택하기 (0) | 2018.03.04 |
[C#/WINFORM] PropertyGrid 클래스 사용하기 (0) | 2018.03.04 |
[C#/WINFORM] GroupBox 클래스 : 테두리 색상 설정하기 (0) | 2018.03.04 |
[C#/WINFORM] Form 클래스 : 폼 닫히는 것을 방지하기 (0) | 2018.03.04 |
[C#/WINFORM] 크로스 스레드(Cross Thread) 처리하기 (0) | 2018.03.04 |
[C#/WINFORM] 크로스 스레드(Cross Thread) 처리하기 (0) | 2018.03.04 |
댓글을 달아 주세요