[DEVEXPRESS/WINFORM] PropertyGridControl 클래스 : TabPanelCustomize 이벤트를 사용해 탭 패널 커스텀 설정하기
DevExpress/WinForm 2020. 5. 2. 19:04728x90
반응형
728x170
▶ MainForm.cs
using System;
using System.Data.OleDb;
using System.Drawing;
using DevExpress.Utils.Svg;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraVerticalGrid;
using DevExpress.XtraVerticalGrid.Events;
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.propertyGridControl.ActiveViewType = PropertyGridView.Office;
#endregion
#region 이벤트를 설정한다.
this.lookUpEdit.Properties.EditValueChanged += lookUpEdit_Properties_EditValueChanged;
this.propertyGridControl.TabPanelCustomize += propertyGridControl_TabPanelCustomize;
#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
#region 속성 그리드 컨트롤 탭 패널 커스텀 설정하기 - propertyGridControl_TabPanelCustomize(sender, e)
/// <summary>
/// 속성 그리드 컨트롤 탭 패널 커스텀 설정하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void propertyGridControl_TabPanelCustomize(object sender, TabPanelCustomizeEventArgs e)
{
PropertyGridControl propertyGridControl = sender as PropertyGridControl;
Tab mainTab = new Tab();
mainTab.Caption = "메인";
mainTab.ImageOptions.SvgImageSize = new Size(16, 16);
mainTab.ImageOptions.SvgImage = SvgBitmap.FromFile(@"IMAGE\pages.svg").SvgImage;
mainTab.FieldNames.Add("ProductID" );
mainTab.FieldNames.Add("ProductName");
mainTab.FieldNames.Add("SupplierID" );
mainTab.FieldNames.Add("CategoryID" );
Tab otherTab = new Tab();
otherTab.Caption = "기타";
otherTab.ImageOptions.SvgImageSize = new Size(16, 16);
otherTab.ImageOptions.SvgImage = SvgBitmap.FromFile(@"IMAGE\medium.svg").SvgImage;
otherTab.FieldNames.Add("QuantityPerUnit");
otherTab.FieldNames.Add("UnitPrice" );
otherTab.FieldNames.Add("UnitsInStock" );
otherTab.FieldNames.Add("UnitsOnOrder" );
otherTab.FieldNames.Add("ReorderLevel" );
otherTab.FieldNames.Add("Discontinued" );
otherTab.FieldNames.Add("EAN13" );
e.Buttons.Add(mainTab);
e.Buttons.Add(otherTab);
propertyGridControl.SelectedTab = propertyGridControl.Tabs[0];
}
#endregion
}
}
728x90
반응형
그리드형(광고전용)
댓글을 달아 주세요