첨부 소스 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

TestProject.zip
다운로드

▶ MainForm.cs

using System;
using System.Data.OleDb;

using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;

namespace TestProject
{
    /// <summary>
    /// 메인 폼
    /// </summary>
    public partial class MainForm : XtraForm
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Field
        ////////////////////////////////////////////////////////////////////////////////////////// Private

        #region Field

        /// <summary>
        /// 연결
        /// </summary>
        private OleDbConnection connection;

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - MainForm()

        /// <summary>
        /// 생성자
        /// </summary>
        public MainForm()
        {
            InitializeComponent();

            this.connection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=nwind.mdb");

            #region 룩업 에디터를 설정한다.

            this.lookUpEdit.Properties.PopupWidth    = 320;
            this.lookUpEdit.Properties.DisplayMember = "ProductID";

            #region 제품 ID 컬럼을 추가한다.

            LookUpColumnInfo productIDColumnInfo = new LookUpColumnInfo();

            productIDColumnInfo.Caption   = "제품 ID";
            productIDColumnInfo.FieldName = "ProductID";
            productIDColumnInfo.Width     = 100;

            this.lookUpEdit.Properties.Columns.Add(productIDColumnInfo);

            #endregion
            #region 제품명 컬럼을 추가한다.

            LookUpColumnInfo productNameColumnInfo = new LookUpColumnInfo();

            productNameColumnInfo.Caption   = "제품명";
            productNameColumnInfo.FieldName = "ProductName";
            productNameColumnInfo.Width     = 200;

            this.lookUpEdit.Properties.Columns.Add(productNameColumnInfo);

            this.lookUpEdit.Properties.DataSource = Product.GetProductList(this.connection);

            #endregion

            #endregion
            #region 이벤트를 설정한다.

            this.lookUpEdit.Properties.EditValueChanged += lookUpEdit_Properties_EditValueChanged;

            #endregion
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Private

        #region 룩업 에디터 속성 편집 값 변경시 처리하기 - lookUpEdit_Properties_EditValueChanged(sender, e)

        /// <summary>
        /// 룩업 에디터 속성 편집 값 변경시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void lookUpEdit_Properties_EditValueChanged(object sender, EventArgs e)
        {
            this.propertyGridControl.SelectedObject = this.lookUpEdit.EditValue as Product;
        }

        #endregion
    }
}
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요