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

TestProject.zip
다운로드

▶ 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
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요