コード例 #1
0
        private void btnLoad_Click(object sender, EventArgs e)
        {
            try {
                gridData.DataSource = "";
                gridData.Refresh();
                //disable Datagrid sorting capability
                gridData.Columns.Cast <DataGridViewColumn>().
                ToList().ForEach(f => f.SortMode = DataGridViewColumnSortMode.NotSortable);

                gridData.Columns.Clear();

                if (gridData.Rows.Count > 0)
                {
                    gridData.Rows.Clear();
                }

                var dataset   = Import(txtFileLocation.Text.ToString(), true);
                var tempTable = dataset.Tables[0];


                tempTable.DefaultView.Sort = "ProjID";
                tempTable           = tempTable.DefaultView.ToTable();
                tempTable           = RemoveUnUsedColumnsAndAddNewColumns(tempTable);
                tempTable           = UpdateRegionImpact(tempTable);
                gridData.DataSource = tempTable;

                DataGridViewComboBoxColumn americasComboBox = new DataGridViewComboBoxColumn();
                americasComboBox.DataSource    = Americas.GetAmericas();
                americasComboBox.DisplayMember = "eName";
                americasComboBox.ValueMember   = "eEmail";
                gridData.Columns.Insert(6, americasComboBox);
                gridData.Columns[6].HeaderText = "Americas";

                DataGridViewComboBoxColumn emeaComboBox = new DataGridViewComboBoxColumn();
                emeaComboBox.DataSource    = EMEA.GetAmericas();
                emeaComboBox.DisplayMember = "eName";
                emeaComboBox.ValueMember   = "eEmail";
                gridData.Columns.Insert(7, emeaComboBox);
                gridData.Columns[7].HeaderText = "EMEA";

                DataGridViewComboBoxColumn apacComboBox = new DataGridViewComboBoxColumn();
                apacComboBox.DataSource    = APAC.GetAmericas();
                apacComboBox.DisplayMember = "eName";
                apacComboBox.ValueMember   = "eEmail";
                gridData.Columns.Insert(8, apacComboBox);
                gridData.Columns[8].HeaderText = "APAC";

                AssignRegionToNPI();

                gridData.Columns[6].Visible   = false;
                gridData.Columns[7].Visible   = false;
                gridData.Columns[8].Visible   = false;
                gridData.Columns[13].ReadOnly = true;
            }
            catch (Exception ex) {
                MessageBox.Show(ex.StackTrace.ToString(), "NPI Tracker - FirstForm", MessageBoxButtons.OK);
            }
        }
コード例 #2
0
        void AddRegionFieldEmployees()
        {
            cmbfieldAmericas.DataSource    = Americas.GetAmericas();
            cmbfieldAmericas.DisplayMember = "eName";
            cmbfieldAmericas.ValueMember   = "eEmail";

            cmbfieldEMEA.DataSource    = EMEA.GetAmericas();
            cmbfieldEMEA.DisplayMember = "eName";
            cmbfieldEMEA.ValueMember   = "eEmail";

            cmbfieldAPAC.DataSource    = APAC.GetAmericas();
            cmbfieldAPAC.DisplayMember = "eName";
            cmbfieldAPAC.ValueMember   = "eEmail";
        }