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

TestProject.zip
다운로드

▶ DSBandedGridView.cs

using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;

using DevExpress.Utils;
using DevExpress.Utils.Drawing;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraGrid.Drawing;
using DevExpress.XtraGrid.Views.BandedGrid;
using DevExpress.XtraGrid.Views.BandedGrid.Drawing;
using DevExpress.XtraGrid.Views.BandedGrid.ViewInfo;
using DevExpress.XtraGrid.Views.Grid;

namespace TestProject
{
    /// <summary>
    /// 확장 밴드 그리드 뷰
    /// </summary>
    public class DSBandedGridView : BandedGridView
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Field
        ////////////////////////////////////////////////////////////////////////////////////////// Static
        //////////////////////////////////////////////////////////////////////////////// Private

        #region Field

        /// <summary>
        /// 스키 오프셋 정렬 리스트
        /// </summary>
        private static SortedList<string, int> _skinOffsetSortedList = new SortedList<string, int>();

        #endregion

        ////////////////////////////////////////////////////////////////////////////////////////// Instance
        //////////////////////////////////////////////////////////////////////////////// Private

        #region Field

        /// <summary>
        /// 병합 그리드 밴드 딕셔너리
        /// </summary>
        private Dictionary<GridBand, int> mergedGridBandDictionary = new Dictionary<GridBand, int>();

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Static

        #region 생성자 - DSBandedGridView()

        /// <summary>
        /// 생성자
        /// </summary>
        static DSBandedGridView()
        {
            _skinOffsetSortedList.Add("Black"             , 1);
            _skinOffsetSortedList.Add("Blue"              , 1);
            _skinOffsetSortedList.Add("Caramel"           , 1);
            _skinOffsetSortedList.Add("Coffee"            , 0);
            _skinOffsetSortedList.Add("Dark Side"         , 1);
            _skinOffsetSortedList.Add("Darkroom"          , 1);
            _skinOffsetSortedList.Add("DevExpress Style"  , 0);
            _skinOffsetSortedList.Add("Foggy"             , 0);
            _skinOffsetSortedList.Add("Glass Oceans"      , 1);
            _skinOffsetSortedList.Add("High Contrast"     , 0);
            _skinOffsetSortedList.Add("iMaginary"         , 1);
            _skinOffsetSortedList.Add("Lilian"            , 1);
            _skinOffsetSortedList.Add("Liquid Sky"        , 1);
            _skinOffsetSortedList.Add("London Liquid Sky" , 1);
            _skinOffsetSortedList.Add("McSkin"            , 1);
            _skinOffsetSortedList.Add("Metropolis"        , 0);
            _skinOffsetSortedList.Add("Money Twins"       , 1);
            _skinOffsetSortedList.Add("Office 2007 Black" , 1);
            _skinOffsetSortedList.Add("Office 2007 Blue"  , 1);
            _skinOffsetSortedList.Add("Office 2007 Green" , 1);
            _skinOffsetSortedList.Add("Office 2007 Pink"  , 1);
            _skinOffsetSortedList.Add("Office 2007 Silver", 1);
            _skinOffsetSortedList.Add("Office 2010 Black" , 0);
            _skinOffsetSortedList.Add("Office 2010 Blue"  , 0);
            _skinOffsetSortedList.Add("Office 2010 Silver", 0);
            _skinOffsetSortedList.Add("Pumpkin"           , 1);
            _skinOffsetSortedList.Add("Seven"             , 0);
            _skinOffsetSortedList.Add("Seven Classic"     , 0);
            _skinOffsetSortedList.Add("Sharp"             , 0);
            _skinOffsetSortedList.Add("Sharp Plus"        , 1);
            _skinOffsetSortedList.Add("Springtime"        , 1);
            _skinOffsetSortedList.Add("Stardust"          , 1);
            _skinOffsetSortedList.Add("Summer 2008"       , 1);
            _skinOffsetSortedList.Add("The Asphalt World" , 1);
            _skinOffsetSortedList.Add("Valentine"         , 1);
            _skinOffsetSortedList.Add("VS2010"            , 0);
            _skinOffsetSortedList.Add("Xmas 2008 Blue"    , 1);
        }

        #endregion

        ////////////////////////////////////////////////////////////////////////////////////////// Instance
        //////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - ExBandedGridView()

        /// <summary>
        /// 생성자
        /// </summary>
        public DSBandedGridView()
        {
        }

        #endregion
        #region 생성자 - ExBandedGridView(gridControl)

        /// <summary>
        /// 생성자
        /// </summary>
        /// <param name="gridControl">그리드 컨트롤</param>
        public DSBandedGridView(GridControl gridControl) : base(gridControl)
        {
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 컬럼 헤더 병합 이벤트 추가하기 - AddColumnHeaderMergeEvent()

        /// <summary>
        /// 컬럼 헤더 병합 이벤트 추가하기
        /// </summary>
        public void AddColumnHeaderMergeEvent()
        {
            base.GridControl.Paint      += GridControl_Paint;
            base.CustomDrawBandHeader   += bandedGridView_CustomDrawBandHeader;
            base.CustomDrawColumnHeader += bandedGridView_CustomDrawColumnHeader;

            foreach(GridBand band in this.mergedGridBandDictionary.Keys)
            {
                foreach(GridColumn column in band.Columns)
                {
                    column.OptionsFilter.AllowFilter = false;
                }
            }
        }

        #endregion
        #region 병합 밴드 설정하기 - SetMergeBand(gridBandArray)

        /// <summary>
        /// 병합 밴드 설정하기
        /// </summary>
        /// <param name="gridBandArray">그리드 밴드 배열</param>
        public void SetMergeBand(params GridBand[] gridBandArray)
        {
            this.mergedGridBandDictionary.Clear();

            SetNoChildrenGridBandDictionary(this.mergedGridBandDictionary, gridBandArray);
        }

        #endregion
        #region 컬럼 헤더 병합 이벤트 제거하기 - RemoveColumnHeaderMergeEvent()

        /// <summary>
        /// 컬럼 헤더 병합 이벤트 제거하기
        /// </summary>
        public void RemoveColumnHeaderMergeEvent()
        {
            base.GridControl.Paint      -= GridControl_Paint;
            base.CustomDrawBandHeader   -= bandedGridView_CustomDrawBandHeader;
            base.CustomDrawColumnHeader -= bandedGridView_CustomDrawColumnHeader;

            foreach(GridBand band in this.mergedGridBandDictionary.Keys)
            {
                foreach(GridColumn column in band.Columns)
                {
                    column.OptionsFilter.AllowFilter = true;
                }
            }
        }

        #endregion

        ////////////////////////////////////////////////////////////////////////////////////////// Private
        //////////////////////////////////////////////////////////////////////////////// Event

        #region 그리드 컨트롤 PAINT 처리하기 - GridControl_Paint(sender, e)

        /// <summary>
        /// 그리드 컨트롤 PAINT 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void GridControl_Paint(object sender, PaintEventArgs e)
        {
            foreach(KeyValuePair<GridBand, int> keyValuePair in this.mergedGridBandDictionary)
            {
                foreach(BandedGridColumn column in keyValuePair.Key.Columns)
                {
                    DrawColumnHeader(this, base.Painter, new GraphicsCache(e.Graphics), column, keyValuePair.Value);
                }
            }
        }

        #endregion
        #region 밴드 그리드 뷰 커스텀 밴드 헤더 그리기 - bandedGridView_CustomDrawBandHeader(sender, e)

        /// <summary>
        /// 밴드 그리드 뷰 커스텀 밴드 헤더 그리기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void bandedGridView_CustomDrawBandHeader(object sender, BandHeaderCustomDrawEventArgs e)
        {
            if(e.Band != null)
            {
                if(this.mergedGridBandDictionary.ContainsKey(e.Band))
                {
                    this.mergedGridBandDictionary[e.Band] = (int)(e.Graphics.ClipBounds.X);

                    e.Handled = true;
                }
            }
        }

        #endregion
        #region 밴드 그리드 뷰 커스텀 컬럼 헤더 그리기 - bandedGridView_CustomDrawColumnHeader(sender, e)

        /// <summary>
        /// 밴드 그리드 뷰 커스텀 컬럼 헤더 그리기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void bandedGridView_CustomDrawColumnHeader(object sender, ColumnHeaderCustomDrawEventArgs e)
        {
            BandedGridColumn column = e.Column as BandedGridColumn;

            if((column != null) && this.mergedGridBandDictionary.ContainsKey(column.OwnerBand))
            {
                e.Handled = true;
            }
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////// Function

        #region 그리드 밴드 정보 인자들 구하기 - GetGridBandInfoArgs(gridBandInfoCollection, gridBand)

        /// <summary>
        /// 그리드 밴드 정보 인자들 구하기
        /// </summary>
        /// <param name="gridBandInfoCollection">그리드 밴드 정보 컬렉션</param>
        /// <param name="gridBand">그리드 밴드</param>
        /// <returns>그리드 밴드 정보 인자들</returns>
        private GridBandInfoArgs GetGridBandInfoArgs(GridBandInfoCollection gridBandInfoCollection, GridBand gridBand)
        {
            GridBandInfoArgs gridBandInfoArgs = gridBandInfoCollection[gridBand];

            if(gridBandInfoArgs != null)
            {
                return gridBandInfoArgs;
            }

            foreach(GridBandInfoArgs gridBandInfoArgs2 in gridBandInfoCollection)
            {
                if(gridBandInfoArgs2.Children != null)
                {
                    gridBandInfoArgs = GetGridBandInfoArgs(gridBandInfoArgs2.Children, gridBand);

                    if(gridBandInfoArgs != null)
                    {
                        return gridBandInfoArgs;
                    }
                }
            }

            return null;
        }

        #endregion
        #region 컬럼 헤더 그리기 - DrawColumnHeader(bandedGridView, bandedGridPainter, graphicsCache, gridColumn, offset)

        /// <summary>
        /// 컬럼 헤더 그리기
        /// </summary>
        /// <param name="bandedGridView">밴드 그리드 뷰</param>
        /// <param name="bandedGridPainter">밴드 그리드 페인터</param>
        /// <param name="graphicsCache">그래픽스 캐시</param>
        /// <param name="gridColumn">그리드 컬럼</param>
        /// <param name="offset">오프셋</param>
        private void DrawColumnHeader(BandedGridView bandedGridView, BandedGridPainter bandedGridPainter, GraphicsCache graphicsCache, GridColumn gridColumn, int offset)
        {
            BandedGridViewInfo bandedGridViewInfo = bandedGridView.GetViewInfo() as BandedGridViewInfo;
            GridColumnInfoArgs gridColumnInfoArgs = bandedGridViewInfo.ColumnsInfo[gridColumn];
            GridBandInfoArgs   gridBandInfoArgs   = GetGridBandInfoArgs(bandedGridViewInfo.BandsInfo, (gridColumn as BandedGridColumn).OwnerBand);

            if((gridColumnInfoArgs != null) && (gridBandInfoArgs != null))
            {
                gridColumnInfoArgs.Cache = graphicsCache;

                int       top       = gridBandInfoArgs.Bounds.Top;
                Rectangle rectangle = gridColumnInfoArgs.Bounds;
                int       delta     = rectangle.Top - top;

                int skinOffset = _skinOffsetSortedList[bandedGridView.GridControl.LookAndFeel.ActiveSkinName];

                rectangle.Y      =  top   + skinOffset;
                rectangle.Height += delta - skinOffset;

                gridColumnInfoArgs.Bounds = rectangle;

                GraphicsClipState graphicsClipState = null;

                if(bandedGridViewInfo.HasFixedLeft && (gridBandInfoArgs.Fixed != FixedStyle.Left))
                {
                    GridBandInfoArgs fixedGridBandInfoArgs = GetGridBandInfoArgs(bandedGridViewInfo.BandsInfo, bandedGridViewInfo.FixedLeftBand);

                    if(rectangle.X < fixedGridBandInfoArgs.Bounds.Right)
                    {
                        offset = fixedGridBandInfoArgs.Bounds.Right;
                    }
                }

                if(rectangle.X < offset)
                {
                    rectangle.X = offset;

                    graphicsClipState = graphicsCache.ClipInfo.SaveClip();

                    graphicsCache.ClipInfo.SetClip(rectangle);
                }

                gridColumnInfoArgs.Appearance.TextOptions.VAlignment = VertAlignment.Center;

                bandedGridPainter.ElementsPainter.Column.CalcObjectBounds(gridColumnInfoArgs);
                bandedGridPainter.ElementsPainter.Column.DrawObject(gridColumnInfoArgs);

                if(graphicsClipState != null)
                {
                    graphicsCache.ClipInfo.RestoreClip(graphicsClipState);
                }
            }
        }

        #endregion
        #region 자식 없는 그리드 밴드 딕셔너리 설정하기 - SetNoChildrenGridBandDictionary(sourceDictionary, gridBandArray)

        /// <summary>
        /// 자식 없는 그리드 밴드 딕셔너리 설정하기
        /// </summary>
        /// <param name="sourceDictionary">소스 딕셔너리</param>
        /// <param name="gridBandArray">그리드 밴드 배열</param>
        private void SetNoChildrenGridBandDictionary(Dictionary<GridBand, int> sourceDictionary, GridBand[] gridBandArray)
        {
            foreach(GridBand band in gridBandArray)
            {
                if(!band.HasChildren)
                {
                    sourceDictionary.Add(band, -1);
                }
            }
        }

        #endregion
    }
}

 

728x90

 

▶ MainForm.cs

using System;
using System.Data;
using System.Drawing;
using System.Windows.Forms;

using DevExpress.Data;
using DevExpress.Utils;
using DevExpress.XtraEditors.Repository;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraGrid.Views.BandedGrid;
using DevExpress.XtraGrid.Views.Grid;

namespace TestProject
{
    /// <summary>
    /// 메인 폼
    /// </summary>
    public partial class MainForm : Form
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - MainForm()

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

            // 밴드 그리드 뷰를 초기화 한다.
            InitializeBandedGridView(this.bandedGridView);

            // 밴드 그리드 뷰에서 특정 밴드 컬럼 헤더를 병합한다.
            this.bandedGridView.AddColumnHeaderMergeEvent();

            this.bandedGridView.SetMergeBand(this.bandedGridView.Bands["idBand"]);

            // 이벤트를 설정한다.
            Load += Form_Load;
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Private
        //////////////////////////////////////////////////////////////////////////////// Event

        #region 폼 로드시 처리하기 - Form_Load(sender, e)

        /// <summary>
        /// 폼 로드시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void Form_Load(object sender, EventArgs e)
        {
            DataTable table = GetSampleDataTable();

            this.gridControl.DataSource = table;
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////// Function

        #region 그리드 밴드 구하기 - GetGridBand(name, width, caption, horzAlignment, vertAlignment)

        /// <summary>
        /// 그리드 밴드 구하기
        /// </summary>
        /// <param name="name">명칭</param>
        /// <param name="width">너비</param>
        /// <param name="caption">제목</param>
        /// <param name="horzAlignment">수평 정렬</param>
        /// <param name="vertAlignment">수직 정렬</param>
        /// <returns>그리드 밴드</returns>
        private GridBand GetGridBand(string name, int width, string caption, HorzAlignment horzAlignment, VertAlignment vertAlignment)
        {
            GridBand band = new GridBand();

            band.Name                                    = name;
            band.Width                                   = width;
            band.Caption                                 = caption;
            band.AppearanceHeader.Options.UseTextOptions = true;
            band.AppearanceHeader.TextOptions.HAlignment = horzAlignment;
            band.AppearanceHeader.TextOptions.VAlignment = vertAlignment;

            return band;
        }

        #endregion
        #region 밴드 그리드 컬럼 구하기 - GetBandedGridColumn(caption, fieldName, unboundColumnType, width, horzAlignment, allowEdit, formatType, formatString, columnEdit)

        /// <summary>
        /// 밴드 그리드 컬럼 구하기
        /// </summary>
        /// <param name="caption">제목</param>
        /// <param name="fieldName">필드명</param>
        /// <param name="unboundColumnType">언바운드 컬럼 타입</param>
        /// <param name="width">너비</param>
        /// <param name="horzAlignment">수평 정렬</param>
        /// <param name="allowEdit">편집 허용 여부</param>
        /// <param name="formatType">포맷 타입</param>
        /// <param name="formatString">포맷 문자열</param>
        /// <param name="columnEdit">컬럼 에디터</param>
        /// <returns>밴드 그리드 컬럼</returns>
        private BandedGridColumn GetBandedGridColumn(string caption, string fieldName, UnboundColumnType unboundColumnType, int width, HorzAlignment horzAlignment,
            bool allowEdit, FormatType formatType, string formatString, RepositoryItem columnEdit = null)
        {
            BandedGridColumn column = new BandedGridColumn();

            column.Name                                    = string.Empty;
            column.Caption                                 = caption;
            column.FieldName                               = fieldName;
            column.UnboundType                             = unboundColumnType;
            column.AutoFillDown                            = true;
            column.AppearanceHeader.Options.UseTextOptions = true;
            column.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
            column.AppearanceCell.Options.UseTextOptions   = true;
            column.AppearanceCell.TextOptions.HAlignment   = horzAlignment;
            column.OptionsColumn.AllowEdit                 = allowEdit;
            column.DisplayFormat.FormatType                = formatType;
            column.DisplayFormat.FormatString              = formatString;
            column.Visible                                 = true;
            column.ColumnEdit                              = columnEdit;

            return column;
        }

        #endregion
        #region 밴드 그리드 뷰 초기화 하기 - InitializeBandedGridView(bandedGridView)

        /// <summary>
        /// 밴드 그리드 뷰 초기화 하기
        /// </summary>
        /// <param name="bandedGridView">밴드 그리드 뷰</param>
        private void InitializeBandedGridView(BandedGridView bandedGridView)
        {
            bandedGridView.OptionsBehavior.Editable                 = true;
            bandedGridView.OptionsBehavior.EditorShowMode           = EditorShowMode.MouseDown;
            bandedGridView.OptionsCustomization.AllowColumnMoving   = false;
            bandedGridView.OptionsCustomization.AllowColumnResizing = true;
            bandedGridView.OptionsCustomization.AllowFilter         = false;
            bandedGridView.OptionsCustomization.AllowSort           = false;
            bandedGridView.OptionsMenu.EnableColumnMenu             = false;
            bandedGridView.OptionsSelection.MultiSelect             = false;
            bandedGridView.OptionsSelection.MultiSelectMode         = GridMultiSelectMode.CellSelect;
            bandedGridView.OptionsView.ColumnAutoWidth              = false;
            bandedGridView.OptionsView.EnableAppearanceEvenRow      = true;
            bandedGridView.OptionsView.ShowGroupPanel               = false;
            bandedGridView.OptionsView.ShowIndicator                = false;

            bandedGridView.Appearance.BandPanel.Font   = new Font("나눔고딕코딩", 12f);
            bandedGridView.Appearance.HeaderPanel.Font = new Font("나눔고딕코딩", 12f);
            bandedGridView.Appearance.Row.Font         = new Font("나눔고딕코딩", 12f);

            bandedGridView.Bands.Clear();

            GridBand idBand      = GetGridBand("idBand"     , 100, " "   , HorzAlignment.Center, VertAlignment.Center);
            GridBand schoolBand  = GetGridBand("schoolBand" , 300, "학교", HorzAlignment.Center, VertAlignment.Center);
            GridBand studentBand = GetGridBand("studentBand", 400, "학생", HorzAlignment.Center, VertAlignment.Center);

            BandedGridColumn idColumn            = GetBandedGridColumn("ID"    , "ID"           , UnboundColumnType.Integer, 100, HorzAlignment.Far , true, FormatType.Numeric, "###0"    , null);
            BandedGridColumn schoolNameColumn    = GetBandedGridColumn("학교명", "SchoolName"   , UnboundColumnType.String , 100, HorzAlignment.Near, true, FormatType.None   , null      , null);
            BandedGridColumn schoolAddressColumn = GetBandedGridColumn("주소"  , "SchoolAddress", UnboundColumnType.String , 200, HorzAlignment.Near, true, FormatType.None   , null      , null);
            BandedGridColumn studentNameColumn   = GetBandedGridColumn("성명"  , "StudentName"  , UnboundColumnType.String , 100, HorzAlignment.Near, true, FormatType.None   , null      , null);
            BandedGridColumn studentHeightColumn = GetBandedGridColumn("키"    , "StudentHeight", UnboundColumnType.Integer, 100, HorzAlignment.Far , true, FormatType.Numeric, "#,##0.00", null);
            BandedGridColumn studentWeightColumn = GetBandedGridColumn("체중"  , "StudentWeight", UnboundColumnType.Integer, 100, HorzAlignment.Far , true, FormatType.Numeric, "#,##0.00", null);
            BandedGridColumn studentScoreColumn  = GetBandedGridColumn("점수"  , "StudentScore" , UnboundColumnType.Integer, 100, HorzAlignment.Far , true, FormatType.Numeric, "#,##0"   , null);

            idBand     .Columns.Add(idColumn           );
            schoolBand .Columns.Add(schoolNameColumn   );
            schoolBand .Columns.Add(schoolAddressColumn);
            studentBand.Columns.Add(studentNameColumn  );
            studentBand.Columns.Add(studentHeightColumn);
            studentBand.Columns.Add(studentWeightColumn);
            studentBand.Columns.Add(studentScoreColumn );

            bandedGridView.Columns.Add(idColumn           );
            bandedGridView.Columns.Add(schoolNameColumn   );
            bandedGridView.Columns.Add(schoolAddressColumn);
            bandedGridView.Columns.Add(studentNameColumn  );
            bandedGridView.Columns.Add(studentHeightColumn);
            bandedGridView.Columns.Add(studentWeightColumn);
            bandedGridView.Columns.Add(studentScoreColumn );

            bandedGridView.Bands.Add(idBand     );
            bandedGridView.Bands.Add(schoolBand );
            bandedGridView.Bands.Add(studentBand);

            bandedGridView.Bands["idBand"].Fixed = FixedStyle.Left;
        }

        #endregion
        #region 샘플 데이터 테이블 구하기 - GetSampleDataTable()

        /// <summary>
        /// 샘플 데이터 테이블 구하기
        /// </summary>
        /// <returns>샘플 데이터 테이블</returns>
        private DataTable GetSampleDataTable()
        {
            DataTable table = new DataTable();

            table.Columns.Add("ID"           , typeof(int   ));
            table.Columns.Add("SchoolName"   , typeof(string));
            table.Columns.Add("SchoolAddress", typeof(string));
            table.Columns.Add("StudentName"  , typeof(string));
            table.Columns.Add("StudentHeight", typeof(int   ));
            table.Columns.Add("StudentWeight", typeof(int   ));
            table.Columns.Add("StudentScore" , typeof(int   ));

            Random random = new Random(DateTime.Now.Millisecond);

            DataRow row;

            for(int i = 1; i <= 100; i++)
            {
                int    id            = i;
                int    schoolNumber  = random.Next(1, 5);
                string schoolName    = string.Format("학교 {0}", schoolNumber);
                string schoolAddress = string.Format("주소 {0}", schoolNumber);
                string StudentName   = string.Format("학생 {0}", i           );
                int    studentHeight = random.Next(150, 190);
                int    studentWeight = random.Next(50 , 100);
                int    studentScore  = random.Next(70 , 100);

                row = table.NewRow();

                row["ID"           ] = id;
                row["SchoolName"   ] = schoolName;
                row["SchoolAddress"] = schoolAddress;
                row["StudentName"  ] = StudentName;
                row["StudentHeight"] = studentHeight;
                row["StudentWeight"] = studentWeight;
                row["StudentScore" ] = studentScore;

                table.Rows.Add(row);
            }                       
            
            return table;
        }

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

댓글을 달아 주세요