示例#1
0
        private void dtgCompetition()
        {
            metroGrid2.EditMode = DataGridViewEditMode.EditOnEnter;
            //ComboBox 유형의 셀 만들고
            DataGridViewComboBoxColumn[] ComboBoxCell = new DataGridViewComboBoxColumn[mainFrm.selectCompetitionAndSimilarity.Where(c => c).Count() - 1];

            //DisplayStyle을 ComboBox로 설정
            for (int i = 0; i < ComboBoxCell.Count(); i++)
            {
                ComboBoxCell[i]      = new DataGridViewComboBoxColumn();
                ComboBoxCell[i].Name = mainFrm.SelectedCompetitionMenu[i];
                ComboBoxCell[i].Items.Add("열세");
                ComboBoxCell[i].Items.Add("유사");
                ComboBoxCell[i].Items.Add("우세");

                ComboBoxCell[i].DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;
                ComboBoxCell[i].FlatStyle    = FlatStyle.Flat;
            }
            textBox1.Size       = metroGrid2.Size;
            metroGrid2.Location = new Point(textBox1.Location.X, textBox1.Location.Y + textBox1.Size.Height + 1);
            metroGrid2.Rows.Clear();

            metroGrid2.RowHeadersVisible    = false;
            metroGrid2.ColumnHeadersVisible = true;
            metroGrid2.ColumnCount          = 2;

            metroGrid2.Columns[0].Name = "기 종";
            metroGrid2.Columns[1].Name = "단 가";

            for (int i = 0; i < Competition2.CompetitionWeapon.Length; i++)
            {
                metroGrid2.Rows.Add(Competition2.CompetitionWeapon[i]);
                metroGrid2.Rows[i].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                metroGrid2.Rows[i].Cells[0].Style.BackColor   = Color.FromArgb(222, 235, 247);
            }

            metroGrid2.ColumnHeadersDefaultCellStyle.BackColor = Color.FromArgb(32, 56, 100);
            metroGrid2.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
            metroGrid2.ColumnHeadersDefaultCellStyle.Font      = new Font("나눔고딕", 9, FontStyle.Bold);

            DataGridViewColumn dataGridViewColumn = metroGrid2.Columns[0];

            dataGridViewColumn.HeaderCell.Style.BackColor = Color.FromArgb(91, 155, 213);
            dataGridViewColumn.HeaderCell.Style.ForeColor = Color.White;

            // 단가
            DataGridViewColumn dataGridViewColumn2 = metroGrid2.Columns[1];

            dataGridViewColumn2.HeaderCell.Style.BackColor = Color.FromArgb(255, 192, 0);
            dataGridViewColumn2.HeaderCell.Style.ForeColor = Color.Black;


            // 구분 색깔
            for (int i = 0; i < 1; i++)
            {
                metroGrid2.Rows[i].Cells[0].ReadOnly = true;
                metroGrid2.Rows[i].Cells[1].ReadOnly = true;
            }


            int count = 0;

            for (int i = 0; i < mainFrm.selectCompetitionAndSimilarity.Length; i++)
            {
                if (mainFrm.CompetitionData[0, i].ToString().IndexOf("Prices") != -1 ||
                    mainFrm.CompetitionData[0, i].ToString().IndexOf("단가") != -1 ||
                    mainFrm.CompetitionData[0, i].ToString().IndexOf("가격") != -1)
                {
                    continue;
                }

                if (mainFrm.selectCompetitionAndSimilarity[i] == true)
                {
                    metroGrid2.Columns.Add(ComboBoxCell[count]);
                    count++;
                }
            }

            #region 경쟁무기체계 DB에서 추가함

            // 경쟁무기체계를 추가함

            for (int j = 0; j < metroGrid2.RowCount; j++)
            {
                metroGrid2.Rows[j].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                metroGrid2.Rows[j].Cells[1].Style.BackColor   = Color.White;
                //    metroGrid2.Rows[j].Cells[1].Style.ForeColor = Color.White;

                metroGrid2.Rows[j].Cells[1].ReadOnly = true;
            }

            for (int i = 2; i < metroGrid2.ColumnCount; i++)
            {
                for (int j = 0; j < metroGrid2.RowCount; j++)
                {
                    metroGrid2.Rows[j].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                    metroGrid2.Rows[j].Cells[i].Style.BackColor   = Color.White;
                }
            }
            #endregion
            // Design
            metroGrid2.DefaultCellStyle.BackColor = Color.White;

            this.metroGrid2.DefaultCellStyle.Font = new Font("나눔고딕", 9);
            for (int i = 0; i < metroGrid2.RowCount; i++)
            {
                metroGrid2.Rows[i].Cells[0].Style.WrapMode = DataGridViewTriState.False;
            }
            metroGrid2.Columns[0].Width        = 300;
            metroGrid2.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCellsExceptHeader;

            for (int i = 1; i < metroGrid2.ColumnCount; i++)
            {
                metroGrid2.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            }
            foreach (DataGridViewColumn column in metroGrid2.Columns)
            {
                column.SortMode = DataGridViewColumnSortMode.NotSortable;
                column.DefaultCellStyle.Font = new Font("나눔고딕", 9);
            }

            for (int i = 2; i < metroGrid2.ColumnCount; i++)
            {
                for (int j = 0; j < metroGrid2.RowCount; j++)
                {
                    int WeaponIndex = mainFrm.CompetitionWeapon.IndexOf(metroGrid2.Rows[j].Cells[0].Value.ToString());
                    int SpecIndex   = Array.IndexOf(mainFrm.FullSpecCompetitionAndSimilarity, metroGrid2.Columns[i].Name.ToString());

                    metroGrid2.Rows[j].Cells[i].Value = mainFrm.CostEffectiveCompetitionAndSimilar[WeaponIndex, SpecIndex];
                }
            }
            //      metroGrid2.CurrentCell = null;
        }
示例#2
0
        private void dtgCompetition()
        {
            metroGrid2.EditMode = DataGridViewEditMode.EditOnEnter;
            //ComboBox 유형의 셀 만들고
            DataGridViewComboBoxColumn[] ComboBoxCell  = new DataGridViewComboBoxColumn[5];
            DataGridViewComboBoxColumn   ComboBoxCell2 = new DataGridViewComboBoxColumn();

            //      ComboBoxCell.Name = mainFrm.SelectedCompetitionMenu[i];
            for (int i = 0; i < ComboBoxCell.Count(); i++)
            {
                ComboBoxCell[i] = new DataGridViewComboBoxColumn();
                ComboBoxCell[i].Items.Add("매우 높음");
                ComboBoxCell[i].Items.Add("높음");
                ComboBoxCell[i].Items.Add("보통");
                ComboBoxCell[i].Items.Add("낮음");
                ComboBoxCell[i].Items.Add("매우 낮음");

                ComboBoxCell[i].DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;
                ComboBoxCell[i].FlatStyle    = FlatStyle.Flat;
            }


            ComboBoxCell2.Items.Add("국방≫민간");
            ComboBoxCell2.Items.Add("국방>민간");
            ComboBoxCell2.Items.Add("국방≒민간");
            ComboBoxCell2.Items.Add("국방<민간");
            ComboBoxCell2.Items.Add("국방≪민간");

            ComboBoxCell2.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;
            ComboBoxCell2.FlatStyle    = FlatStyle.Flat;


            metroGrid2.Rows.Clear();

            metroGrid2.RowHeadersVisible    = false;
            metroGrid2.ColumnHeadersVisible = true;
            metroGrid2.ColumnCount          = 3;

            metroGrid2.Columns[0].Name = "구 분";
            metroGrid2.Columns[1].Name = "선진국\n기술수준";
            metroGrid2.Columns[2].Name = "국내\n기술수준";


            metroGrid2.ColumnHeadersDefaultCellStyle.BackColor = Color.FromArgb(32, 56, 100);
            metroGrid2.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;


            DataGridViewColumn dataGridViewColumn = metroGrid2.Columns[0];

            dataGridViewColumn.HeaderCell.Style.BackColor = Color.FromArgb(91, 155, 213);
            dataGridViewColumn.HeaderCell.Style.ForeColor = Color.White;


            metroGrid2.Columns.Add(ComboBoxCell[0]);
            metroGrid2.Columns.Add(ComboBoxCell[1]);
            metroGrid2.Columns.Add(ComboBoxCell[2]);
            metroGrid2.Columns.Add(ComboBoxCell[3]);
            metroGrid2.Columns.Add(ComboBoxCell2);
            metroGrid2.Columns.Add(ComboBoxCell[4]);


            metroGrid2.Columns[3].Name = "기술적\n파급효과";
            metroGrid2.Columns[4].Name = "경제적\n파급효과";
            metroGrid2.Columns[5].Name = "보호등급";
            metroGrid2.Columns[6].Name = "기술도입\n가능성";
            metroGrid2.Columns[7].Name = "민군우위\n기술";
            metroGrid2.Columns[8].Name = "난이도";


            this.metroGrid2.DefaultCellStyle.Font = new Font("나눔고딕", 9);
            for (int i = 0; i < metroGrid2.RowCount; i++)
            {
                metroGrid2.Rows[i].Cells[0].Style.WrapMode = DataGridViewTriState.False;
            }
            metroGrid2.Columns[0].Width = 120;

            for (int i = 1; i < metroGrid2.ColumnCount; i++)
            {
                metroGrid2.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            }
            foreach (DataGridViewColumn column in metroGrid2.Columns)
            {
                column.SortMode = DataGridViewColumnSortMode.NotSortable;
                column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                column.DefaultCellStyle.Font      = new Font("나눔고딕", 9);
            }
            if (mainFrm.CriticalTechnology1.Count() == 0)
            {
                metroGrid2.Rows.Add();
                metroGrid2.Rows[0].Cells[0].Style.BackColor = System.Drawing.Color.FromArgb(222, 235, 247);
            }
            else
            {
                for (int i = 0; i < mainFrm.CriticalTechnology1.Count(); i++)
                {
                    metroGrid2.Rows.Add(mainFrm.CriticalTechnology1[i],
                                        mainFrm.CriticalTechnology2[i],
                                        mainFrm.CriticalTechnology3[i],
                                        mainFrm.CriticalTechnology4[i],
                                        mainFrm.CriticalTechnology5[i],
                                        mainFrm.CriticalTechnology6[i],
                                        mainFrm.CriticalTechnology7[i],
                                        mainFrm.CriticalTechnology8[i],
                                        mainFrm.CriticalTechnology9[i]);

                    metroGrid2.Rows[metroGrid2.RowCount - 1].DefaultCellStyle.BackColor = Color.White;
                    metroGrid2.Rows[metroGrid2.RowCount - 1].Cells[0].Style.BackColor   = System.Drawing.Color.FromArgb(222, 235, 247);
                }
            }
            foreach (DataGridViewRow row in metroGrid2.Rows)
            {
                row.Height = (int)(row.Height * 1.2);
            }

            int X = metroGrid2.ColumnHeadersHeight + metroGrid2.Rows.Cast <DataGridViewRow>().Sum(r => r.Height);

            metroGrid2.Height = X + 10;

            bunifuImageButton3.Location = new Point(bunifuImageButton2.Location.X, metroGrid2.Height + metroGrid2.Location.Y + 10);
            bunifuImageButton4.Location = new Point(bunifuImageButton1.Location.X, metroGrid2.Height + metroGrid2.Location.Y + 10);


            metroGrid2.CurrentCell = null;
        }