Esempio n. 1
0
        private Control createGrid(Question q)
        {
            FlowLayoutPanel pnl = new FlowLayoutPanel();

            pnl.FlowDirection = FlowDirection.LeftToRight;
            pnl.Width         = this.contentPanel.Width - 6;
            pnl.WrapContents  = true;

            DataGridViewX dg = new DataGridViewX();

            dg.Enabled     = false;
            dg.Tag         = q;
            dg.ColumnCount = q.GetColumns().Count;
            dg.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;

            // Set the column header style.
            DataGridViewCellStyle columnHeaderStyle = new DataGridViewCellStyle();

            columnHeaderStyle.BackColor      = Color.Aqua;
            dg.BackgroundColor               = Color.White;
            columnHeaderStyle.Font           = new Font("微軟粗黑體", 9, FontStyle.Regular);
            dg.ColumnHeadersDefaultCellStyle = columnHeaderStyle;

            for (int i = 0; i < q.GetColumns().Count; i++)
            {
                GridColumn gc = q.GetColumns()[i];
                dg.Columns[i].Name = gc.GetName();
                if (!string.IsNullOrEmpty(gc.GetWidth()))
                {
                    dg.Columns[i].Width = int.Parse(gc.GetWidth());
                }
            }

            dg.Width  = pnl.Width - 10;
            dg.Height = 120;
            FillGridDefaultRecord(dg);

            dg.CellEndEdit += new DataGridViewCellEventHandler(dg_CellEndEdit);
            pnl.Height      = dg.Height + 6;
            this.allQControls.Add(q.GetQuestionName(), dg);
            pnl.Controls.Add(dg);

            this.contentPanel.Height = pnl.Height + 6;
            this.pnlQGroup.Height    = this.contentPanel.Height + 6;
            return(pnl);
        }