コード例 #1
0
ファイル: Form1.cs プロジェクト: yyangrns/winforms-demos
        /// <summary>
        /// Form Constructor
        /// </summary>
        public MultipleViewForm()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.GridSettings();

            #region Buffer text
            gridControl1.Model.TextDataExchange.PasteTextFromBuffer(
                "1\tDavolio	Nancy\r\n" +
                "2\tFuller	Andrew\r\n"+
                "3\tLeverling	Janet\r\n"+
                "4\tPeacock	Margaret\r\n" +
                "5\tBuchanan	Steven\r\n"+
                "6\tSuyama	Michael\r\n"+
                "7\tKing	Robert\r\n"+
                "8\tCallahan	Laura\r\n"+
                "9\tDodsworth	Anne\r\n",
                GridRangeInfo.Cell(1, 1), int.MaxValue);
            #endregion

            #region Style Info
            GridStyleInfo standard = gridControl1.BaseStylesMap["Standard"].StyleInfo;
            //System.IO.Stream strm = null;
            ImageList imageList = new ImageList();

            System.IO.Stream strm     = null;
            string           iconName = "MultipleViews.user.ico";
            strm = this.GetType().Assembly.GetManifestResourceStream(iconName);
            Icon icon = new Icon(strm);
            imageList.Images.Add(icon.ToBitmap());

            iconName = "MultipleViews.userH.ico";
            strm     = this.GetType().Assembly.GetManifestResourceStream(iconName);
            icon     = new Icon(strm);
            imageList.Images.Add(icon.ToBitmap());

            iconName = "MultipleViews.userJ.ico";
            strm     = this.GetType().Assembly.GetManifestResourceStream(iconName);
            icon     = new Icon(strm);
            imageList.Images.Add(icon.ToBitmap());

            standard.ImageList = imageList;

            int rowIndex = 1;
            int colIndex = 2;
            gridControl1[rowIndex++, colIndex].ImageIndex = 1;
            gridControl1[rowIndex++, colIndex].ImageIndex = 2;
            gridControl1[rowIndex++, colIndex].ImageIndex = 0;
            gridControl1[rowIndex++, colIndex].ImageIndex = 1;
            gridControl1[rowIndex++, colIndex].ImageIndex = 1;
            gridControl1[rowIndex++, colIndex].ImageIndex = 2;
            gridControl1[rowIndex++, colIndex].ImageIndex = 2;
            gridControl1[rowIndex++, colIndex].ImageIndex = 0;
            gridControl1[rowIndex++, colIndex].ImageIndex = 1;

            //gridControl1.Model.Options.DataObjectConsumerOptions = GridDataObjectConsumerOptions.Styles;
            gridControl1.DataObjectConsumerOptions = GridDataObjectConsumerOptions.All;

            GridStyleInfo style;
            style           = new GridStyleInfo();
            style.Interior  = new BrushInfo(Color.White);
            style.TextColor = Color.FromArgb(0x82, 0x2e, 0x1b);
            gridControl1.ChangeCells(GridRangeInfo.Cells(1, 1, 9, 3), style);

            style = new GridStyleInfo();
            style.HorizontalAlignment = GridHorizontalAlignment.Right;
            style.CellValueType       = typeof(int);
            style.Format = "000";
            gridControl1.ChangeCells(GridRangeInfo.Cells(1, 1, 9, 1), style);

            gridControl1.ColWidths.ResizeToFit(GridRangeInfo.Cells(1, 1, 9, 3));

            gridControl1.CommandStack.Enabled = true;

            // Make second grid controls share the same model.
            #endregion

            #region Properties
            this.gridControl1.DefaultRowHeight         = 18;
            this.gridControl1.DefaultColWidth          = 70;
            this.gridControl1.GridVisualStyles         = Syncfusion.Windows.Forms.GridVisualStyles.Office2007Blue;
            this.gridControl1.Properties.GridLineColor = Color.FromArgb(208, 215, 229);
            this.gridControl1.DefaultGridBorderStyle   = Syncfusion.Windows.Forms.Grid.GridBorderStyle.Solid;
            style               = this.gridControl1.BaseStylesMap["Header"].StyleInfo;
            style.TextColor     = System.Drawing.Color.MidnightBlue;
            style.Font.Facename = "Verdana";
            style               = this.gridControl1.BaseStylesMap["Standard"].StyleInfo;
            style.TextColor     = System.Drawing.Color.MidnightBlue;
            style.Font.Facename = "Verdana";
            gridControl2.Model  = gridControl1.Model;
            this.gridControl1.GridVisualStyles = Syncfusion.Windows.Forms.GridVisualStyles.Metro;
            this.gridControl1.Model.ColWidths.ResizeToFit(GridRangeInfo.Table());
            this.gridControl2.GridVisualStyles = Syncfusion.Windows.Forms.GridVisualStyles.Metro;
            #endregion
        }