728x90
728x170
▶ MainForm.cs
using System.Data.OleDb;
using DevExpress.XtraEditors;
using DevExpress.XtraVerticalGrid.Rows;
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");
this.gridControl.DataSource = Order.GetOrderList(this.connection);
this.gridControl.TreeButtonStyle = DevExpress.XtraVerticalGrid.TreeButtonStyle.TreeView;
foreach(EditorRow row in this.gridControl.Rows)
{
row.Properties.AllowEdit = false;
}
EditorRow shipNameRow = this.gridControl.Rows["rowShipName" ] as EditorRow;
EditorRow shipAddressRow = this.gridControl.Rows["rowShipAddress" ] as EditorRow;
EditorRow shipCityRow = this.gridControl.Rows["rowShipCity" ] as EditorRow;
EditorRow shipRegionRow = this.gridControl.Rows["rowShipRegion" ] as EditorRow;
EditorRow shipPostalCodeRow = this.gridControl.Rows["rowShipPostalCode"] as EditorRow;
EditorRow shipCountryRow = this.gridControl.Rows["rowShipCountry" ] as EditorRow;
this.gridControl.Rows.Remove(shipNameRow );
this.gridControl.Rows.Remove(shipAddressRow );
this.gridControl.Rows.Remove(shipCityRow );
this.gridControl.Rows.Remove(shipRegionRow );
this.gridControl.Rows.Remove(shipPostalCodeRow);
this.gridControl.Rows.Remove(shipCountryRow );
CategoryRow shipCategoryRow = new CategoryRow();
shipCategoryRow.Properties.Caption = "Ship";
shipCategoryRow.Expanded = true;
shipCategoryRow.ChildRows.AddRange
(
new BaseRow[]
{
shipNameRow,
shipAddressRow,
shipCityRow,
shipRegionRow,
shipPostalCodeRow,
shipCountryRow
}
);
this.gridControl.Rows.Add(shipCategoryRow);
this.gridControl.BestFit();
}
#endregion
}
}
728x90
그리드형(광고전용)