public static void SetGrid(DataGridViewX dgvX, byte[] data) { if (dgvX.InvokeRequired) { Action <DataGridViewX, byte[]> d = SetGrid; dgvX.Invoke(d, new object[] { dgvX, data }); } else { int length = data.Length; for (int i = 0; i < length; i++) { int row = i / 16; int column = i % 16; dgvX[column, row].Value = Convert.ToString(data[i], 16).PadLeft(2, '0').ToUpper(); } } }
public void HienThi(DataGridViewX dGV, BindingNavigator bN, DateTime ngayCan, String lanCan, String bsx, String chedoCan) { BindingSource bS = new BindingSource(); switch (lanCan) { case "LAN1": bS.DataSource = _PhieuCanData.LayDsPhieuChuaCanLan2(ngayCan, bsx, chedoCan); break; case "LAN2": bS.DataSource = _PhieuCanData.LayDsPhieuCanLan2(ngayCan, bsx, chedoCan); break; default: bS.DataSource = _PhieuCanData.LayDsPhieuCanTatCa(ngayCan, bsx, chedoCan); break; } //bN.BindingSource = bS; //dGV.DataSource = bS; dGV.Invoke(new System.Action(() => dGV.DataSource = bS)); if (bS.Count > 0) { dGV.Columns["DonGia"].DefaultCellStyle.Format = "#,###"; dGV.Columns["KLCanLan1"].DefaultCellStyle.Format = "#,###"; dGV.Columns["KLCanLan2"].DefaultCellStyle.Format = "#,###"; dGV.Columns["Khoiluong"].DefaultCellStyle.Format = "#,###"; dGV.Columns["NgayCanLan1"].DefaultCellStyle.Format = "dd/MM/yyyy"; dGV.Columns["NgayCanLan2"].DefaultCellStyle.Format = "dd/MM/yyyy"; } /* * else * { * //dGV.Columns["ID"].Visible = false; * dGV.Columns["MaNhanVienCanLan1"].Visible = false; * dGV.Columns["MaNhanVienCanLan2"].Visible = false; * dGV.Columns["LanIn"].Visible = false; * } */ }