private void Initialize() { InitializeFlag = true; this.bindingNavigator1.BindingSource = this.customersBindingSource; this.customersBindingSource.DataSource = idg.GetDT(); this.dataGridView1.DataSource = this.customersBindingSource; if (dict == null) { return; } for (int i = 0; i < dataGridView1.Columns.Count; i++) { if (dict.Contains(dataGridView1.Columns[i].Name)) { dataGridView1.Columns[i].HeaderCell.Value = dict[dataGridView1.Columns[i].Name]; } else if (dict.Contains(dataGridView1.Columns[i].Name.ToLower())) { dataGridView1.Columns[i].HeaderCell.Value = dict[dataGridView1.Columns[i].Name.ToLower()]; } dataGridView1.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; if (dataGridView1.Columns[i].ValueType.ToString() == "System.Int32" || dataGridView1.Columns[i].ValueType.ToString() == "System.Int16" || dataGridView1.Columns[i].ValueType.ToString() == "System.Decimal" || dataGridView1.Columns[i].ValueType.ToString() == "System.Single" || dataGridView1.Columns[i].ValueType.ToString() == "System.Double") { dataGridView1.Columns[i].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; } } }
private void Initialize() { InitializeFlag = true; this.bindingNavigator1.BindingSource = this.customersBindingSource; this.customersBindingSource.DataSource = idg.GetDT(); this.dataGridView1.DataSource = this.customersBindingSource; if (dict == null) { return; } for (int i = 0; i < dataGridView1.Columns.Count; i++) { if (dict.Contains(dataGridView1.Columns[i].Name.ToLower())) { dataGridView1.Columns[i].HeaderCell.Value = dict[dataGridView1.Columns[i].Name.ToLower()]; } } }