public void RefreshOrderInfo() { DataTable table = null; table = ctlProductCategory.GetCategoryTable(); this.dgvOrderInfo.DataSource = table; if (!this.dgvOrderInfo.Columns.Contains("checkColumn")) { DataGridViewCheckBoxColumn cc = new DataGridViewCheckBoxColumn(); cc.HeaderText = ""; cc.Name = "checkColumn"; cc.Width = 50; dgvOrderInfo.Columns.Insert(0, cc); } this.dgvOrderInfo.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); int headerW = this.dgvOrderInfo.RowHeadersWidth; int columnsW = 0; DataGridViewColumnCollection columns = this.dgvOrderInfo.Columns; columns[0].Width = 50; for (int i = 0; i < columns.Count; i++) { columnsW += columns[i].Width; } if (columnsW + headerW < this.dgvOrderInfo.Width) { int leftTotalWidht = this.dgvOrderInfo.Width - columnsW - headerW; int eachColumnAddedWidth = leftTotalWidht / (columns.Count - 1); for (int i = 1; i < columns.Count; i++) { columns[i].Width += eachColumnAddedWidth; } } }
void frmProductManage_Shown(object sender, EventArgs e) { ProductCategoryCtl ctlProductCategory = new ProductCategoryCtl(); DataTable table = null; table = ctlProductCategory.GetCategoryTable(); if (table != null && table.Rows.Count > 0) { foreach (DataRow dr in table.Rows) { this.cmbFactory.Items.Add(dr[0]); } } this.refreshDGV(); }
void frmEditEPC_Shown(object sender, EventArgs e) { ProductCategoryCtl ctlProductCategory = new ProductCategoryCtl(); DataTable table = null; table = ctlProductCategory.GetCategoryTable(); if (table != null && table.Rows.Count > 0) { foreach (DataRow dr in table.Rows) { this.comboBox1.Items.Add(dr[0].ToString()); this.categoryCodeIDList.Add(dr[1].ToString()); } } }