수안이의 컴퓨터 연구실

  • Mainpage
  • About Me
  • Tags
  • Metapage
  • Notice
  • Location
  • Keywords
  • Guestbook
  • Admin
  • Write an Article
  • Total | 1620660
  • Today | 40
  • Yesterday | 482

1 Articles, Search for 'PropertyGrid'

  1. 2007/01/23 프로퍼티 그리드 컨트롤을 다루어 보자.
Programming/C#2007/01/23 14:23

프로퍼티 그리드 컨트롤을 다루어 보자.

[프로퍼티 그리드 컨트롤을 다루어 보자.]

프로퍼티 그리드란 이름 그대로 속성의 값을 편집할수 있도록

자동으로 폼디자인을 제공하는 툴이다.

닷넷 편집기에서 사용하는 속성창과 똑같이 작동된다.


사용자 삽입 이미지


우리가 VS.NET툴을 사용하면서 사용하는 속성창과 다를것이 없다.

그럼 이제 컨트롤을 추가하여 작성하는 방법을 알아보도록 하겠다.


사용자 삽입 이미지


먼저 윈도우폼 프로젝트를 하나 새로 만든다. 그리고 왼쪽 도구상자의 메뉴에서 도구 추가삭제를 선택한다.

그러면 아래 쪽에 내려보면 PropertyGrid라는 컨트롤이 있을것이다. 이 컨트롤을 선택한다.


사용자 삽입 이미지


그리고 선택한 컨트롤을 폼위의 올려 놓으면 디자인 타임에서 해야할 작업은 간단하게 끝나게 된다.

이제 속성이 담긴 클래스를 바인딩하는 방법과 카테고리를 나누는 방법을 알아 보도록하자.


먼저 많이 사용하는 데이터 그리드는 데이터 테이블이나 데이터 셋을 바인딩을 시킨다.

이와같이 프로퍼티 그리드는 인스턴스화된 클래스를 바인딩 시키게 된다.

바인딩부분을 살펴보자.


private void Form1_Load(object sender, System.EventArgs e)

{

       ProPertyClass uClass=new ProPertyClass();

       propertyGrid1.SelectedObject=uClass;

}


단순히 클래스를 인스턴스화 하고 SelectedObject에 Object를 전달하여 주는것이로

정말 간단하게 프로그램이 끝나게 되었다. 그럼ProPertyClass라는 클래스에서

사용한 프로퍼티를 살펴보자.


public class ProPertyClass

       {

              public ProPertyClass(){}


              private string _이름;

              private int _나이;

              private Color _색깔;

              private Font _폰트;

              [Category("신상정보"), Description("이름을 적으세요.")]

              public string 이름

              {

                      get{return _이름;}

                      set{_이름=value;}

              }

              [Category("신상정보"), Description("나이를 적으세요.")]

              public int 나이

              {

                      get{return _나이;}

                      set{_나이=value;}

              }

              [Category("_기타"), Description("선의 굵기Size 입니다.")]

              public Color 색깔

              {

                      get{return _색깔;}

                      set{_색깔=value;}

              }

              [Category("기타"), Description("폰트를 선택하세요.")]

              public Font 폰트

              {

                      get{return _폰트;}

                      set{_폰트=value;}

              }

       }


프로퍼티 그리드는 속성의 형식에 맞는 입력 형태를 만들어준다.

그리고 자동으로 Validator체크 하여 준다.

여기서 살펴본것은 Font 타입이나 Color라는 속성을 이용해보았다.

이것뿐만 아니라 배열이나 Array 같은 형식들도 한번 바인딩 하여 사용하여 보자.


사용자 삽입 이미지



전체소스


using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;


namespace PropertyGrid

{

   /// <summary>

   /// Form1에 대한 요약 설명입니다.

   /// </summary>

   public class Form1 : System.Windows.Forms.Form

   {

       private System.Windows.Forms.PropertyGrid propertyGrid1;

       /// <summary>

       /// 필수 디자이너 변수입니다.

       /// </summary>

       private System.ComponentModel.Container components = null;


       public Form1()

       {

           //

           // Windows Form 디자이너 지원에 필요합니다.

           //

           InitializeComponent();


           //

           // TODO: InitializeComponent를 호출한 다음 생성자 코드를 추가합니다.

           //

       }


       /// <summary>

       /// 사용 중인 모든 리소스를 정리합니다.

       /// </summary>

       protected override void Dispose( bool disposing )

       {

           if( disposing )

           {

               if (components != null)

               {

                   components.Dispose();

               }

           }

           base.Dispose( disposing );

       }


       #region Windows Form 디자이너에서 생성한 코드

       /// <summary>

       /// 디자이너 지원에 필요한 메서드입니다.

       /// 이 메서드의 내용을 코드 편집기로 수정하지 마십시오.

       /// </summary>

       private void InitializeComponent()

       {

           this.propertyGrid1 = new System.Windows.Forms.PropertyGrid();

           this.SuspendLayout();

           //

           // propertyGrid1

           //

           this.propertyGrid1.CommandsVisibleIfAvailable = true;

           this.propertyGrid1.LargeButtons = false;

           this.propertyGrid1.LineColor = System.Drawing.SystemColors.ScrollBar;

           this.propertyGrid1.Location = new System.Drawing.Point(152, 8);

           this.propertyGrid1.Name = "propertyGrid1";

           this.propertyGrid1.Size = new System.Drawing.Size(192, 288);

           this.propertyGrid1.TabIndex = 0;

           this.propertyGrid1.Text = "propertyGrid1";

           this.propertyGrid1.ViewBackColor = System.Drawing.SystemColors.Window;

           this.propertyGrid1.ViewForeColor = System.Drawing.SystemColors.WindowText;

           //

           // Form1

           //

           this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);

           this.ClientSize = new System.Drawing.Size(352, 317);

           this.Controls.Add(this.propertyGrid1);

           this.Name = "Form1";

           this.Text = "PropertyGrid";

           this.Load += new System.EventHandler(this.Form1_Load);

           this.ResumeLayout(false);


       }

       #endregion


       /// <summary>

       /// 해당 응용 프로그램의 주 진입점입니다.

       /// </summary>

       [STAThread]

       static void Main()

       {

           Application.Run(new Form1());

       }


       private void Form1_Load(object sender, System.EventArgs e)

       {

           ProPertyClass uClass=new ProPertyClass();

           propertyGrid1.SelectedObject=uClass;

       }

   }

   public class ProPertyClass

   {

       public ProPertyClass(){}


       private string _이름;

       private int _나이;

       private Color _색깔;

       private Font _폰트;

       [Category("신상정보"), Description("이름을 적으세요.")]

       public string 이름

       {

           get{return _이름;}

           set{_이름=value;}

       }

       [Category("신상정보"), Description("나이를 적으세요.")]

       public int 나이

       {

           get{return _나이;}

           set{_나이=value;}

       }

       [Category("_기타"), Description("선의 굵기Size 입니다.")]

       public Color 색깔

       {

           get{return _색깔;}

           set{_색깔=value;}

       }

       [Category("기타"), Description("폰트를 선택하세요.")]

       public Font 폰트

       {

           get{return _폰트;}

           set{_폰트=value;}

       }

   }

}


작성자 : HOONS(박경훈)
이메일 : tajopkh@hanmail.net
홈페이지 : http://www.hoonsbara.com

"C#" 카테고리의 다른 글
  • Low-Level 키보드 입력 후킹 (0)2007/01/25
  • 인터넷 웹 브라우저를 만들어보자. (0)2007/01/23
  • 프로퍼티 그리드 컨트롤을 다루어 보자. (0)2007/01/23
  • 윈도우 종료/재부팅 (0)2006/11/24
  • 해당 드라이브 타입 알아내기 (0)2006/11/24
2007/01/23 14:23 2007/01/23 14:23
Posted by webdizen
Tags PropertyGrid
No Trackback No Comment

Trackback URL : http://www.webdizen.net/blog/trackback/2592

Leave your greetings.

[로그인][오픈아이디란?]

«Prev  1  Next»

RSS HanRSS
Blog Image
webdizen
이 곳은 컴퓨터에 대해 연구하고, 공유하고, 소통하기 위한 연구실입니다. 개인적으로는 OLAP, Data Mining, Semantic Web, Data Modeling에 대해서 연구하고 있습니다.

Categories

전체 (2998)
Webdizen (134)
Life (6)
Diary (16)
Blog (9)
IDEA (1)
Travel (10)
Book (14)
Photo (7)
Movie (7)
Music (13)
Leisure Sports (10)
Funny (5)
Hardware (119)
Software (120)
Windows (5)
Unix & Linux (119)
Installation (4)
Kernel (10)
System (34)
Develop (22)
X-Window (0)
Applicaton (31)
Security (4)
Framework (2)
Hadoop (2)
Programming (805)
Algorithm & Data Structure (1)
Assembly (38)
UNIX/Linux C (95)
C++ (128)
STL (4)
Java (38)
Win32 API (92)
ATL/COM (44)
MFC (151)
.NET (26)
WCF/WPF (4)
C# (28)
Network Programming (17)
Database Programming (12)
OpenGL / DirectX (13)
Multimedia Programming (0)
Game Programming (21)
Parallel Distributed Progra... (0)
Reverse Engineering (0)
Debugging (9)
Python (1)
Ruby (1)
Ruby on Rails (1)
QT (4)
GTK (0)
JSP (0)
PHP (6)
ASP.NET (6)
ASP (3)
Development (28)
Useful Library (2)
Data Modeling (0)
Database (105)
Oracle (4)
MSSQL (41)
MySQL (2)
Data Warehouse (2)
Data Mining (3)
Network (66)
Web (78)
DHTML (4)
XHTML (1)
Javascript (1)
CSS (1)
AJAX (9)
XML (11)
Flex (1)
Silverlight (3)
Security (91)
DoS (1)
Kernel (10)
Scanning (3)
Sniffing (0)
Spoofing (4)
Overflow (28)
Web (11)
Shell (10)
Format String (14)
Window (2)
Embedded (70)
Multimedia (27)
Mobile (14)
Graphic (24)
Management (633)
Knowledge (581)
Hadoop (0)

Notice

  • 메타 블로그 사이트에 등록
  • 새해 맞이 블로그의 변화
  • 블로그 명칭 변경
  • 도메인(www.webdizen.net) 구...
  • TEXTCUBE 1.6.1로 업그레이드...

Tags

  • 웹 2.0
  • 아키텍처
  • Objects
  • Ruby on Rails
  • Migration
  • 영상바이오관
  • 열망
  • 생각
  • 손금
  • C++
  • 화학관
  • 아이콘
  • 타이틀 윈도우
  • Community
  • CakePHP
  • 비전
  • 시스템 사양
  • 연관 분석
  • 강력한 이름
  • 구글수표

Recent Articles

  • ASCII Code의 CRLF 제거 방법.
  • Hadoop 에서 c++ API 이용시....
  • Ubuntu Linux에서 Hadoop 구....
  • 내 심장을 한껏 뛰게한 "국가....
  • 스타 스키마 데이터베이스 설....

Recent Comments

  • ■ 온라인카지노 ▶ http://L....
    asdf 11/21
  • 그리고 혹시 해외여행자보험....
    kim 11/05
  • ★★실제 바다게임장과 똑같....
    asdf 11/04
  • sbsyama.co.to← 짱5000만당....
    asdf 11/04
  • ♡KicaZ??o(???) 바카라사....
    fdsf3fass 11/03

Recent Trackbacks

  • 파일 열기/저장하기 CFileDialog.
    은마군의 나태블록 02/11
  • World IT Show 2008.
    상우 :: Oranzie's BLOG 2008
  • cvs서버 설치하기.
    3인3색 2008
  • 속속 공개되는 Google Chart....
    PHP와 Web 2.0 2007
  • 마방진을 구하는 프로그램.
    Oranzie's BLOG 3 2007

Archive

  • 2009/09 (3)
  • 2009/08 (1)
  • 2009/03 (1)
  • 2009/02 (9)
  • 2009/01 (13)

Calendar

«   2009/11   »
일 월 화 수 목 금 토
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30          

Bookmarks

    • Administration
      • IIS.NET
      • NTFAQ
      • OS의 모든 것
      • 리눅스포털
    • Database
      • SQL Server Central
      • SQL Team
    • Development
      • .NET Heaven
      • ASP Alliance
      • ASP.NET 2.0
      • Bullog.net
      • C# Corner
      • C++ (C PlusPlus.com)
      • C++ Reference
      • CodeGuru
      • CodePlex
      • DebugLab
      • Dev Articles
      • Devpia
      • DotNet Junkies
      • DotNet Zone
      • Driver Online
      • GOSU.NET
      • HOONS 닷넷
      • Joinc 팀블로그
      • KOSR
      • MSDN Home Page
      • OSR Online
      • Sky.ph - 개발자 커뮤니...
      • TAEYO.NET
      • The Code Project
      • WindowsClient.net
      • 김상욱의 개발자 Side
      • 조인시 위키
    • Human Networks
      • belief21c's e-space
      • I think I can
      • Invisible Rover's Blog :D
      • Rodman®
      • ■ Feel So Good~! ■
      • 까만 나비
      • 나를 가꾸는 시간.
      • 나만의 즐거움~~!
      • 단녕
      • 상우 :: Oranzie's BLOG
    • Information Technology
      • Microsoft TechNet
      • 지디넷코리아 - 글로벌...
    • Security
      • FoundStone
      • milw0rm
      • NewOrder
      • OpenRCE
      • Phrack.org
      • Reverse Engineering b1...
      • Reverse Engineering Team
      • RootKit
      • SecurityFocus
      • SecurityXploded by Nag...
      • Wow Hacker
      • Zone-H
Textcube
Louice Studio Inc.
Powered by Textcube. Original designed by Tistory.