private void Init() { if (_type == 0) { //lblDateXNK.Text = "Ngày giờ xuất cảnh"; grdToaTau.Columns["Ten_DoiTac"].HeaderText = "Tên người nhận"; grdToaTau.Columns["Ten_DoanhNghiep"].HeaderText = "Tên người gửi"; } else if (_type == 1) { //lblDateXNK.Text = "Ngày giờ nhập cảnh"; grdToaTau.Columns["Ten_DoiTac"].HeaderText = "Tên người gửi"; grdToaTau.Columns["Ten_DoanhNghiep"].HeaderText = "Tên người nhận"; } //custumize check box column var cusCheckbox = new DataGridViewDisableCheckBoxColumn(); cusCheckbox.Name = "CusCheck"; cusCheckbox.Width = 50; var cbCusHeader = new DatagridViewCheckBoxHeaderCell(); cbCusHeader.OnCheckBoxClicked += new CheckBoxClickedHandler(cbCusHeader_OnCheckBoxClicked); cusCheckbox.HeaderCell = cbCusHeader; cusCheckbox.HeaderText = ""; grdToaTau.Columns.Insert(0, cusCheckbox); //grid Toa tau grdToaTau.AutoGenerateColumns = false; List <tblToaTau> listToaTau = TrainFactory.searchToaTau(_type, _handoverType, txtSoVanTaiDon.Text.Trim(), cbNgayVT.Checked, dtpFrom.Value, dtpTo.Value); grdToaTau.DataSource = listToaTau; // Bind count column for (var i = 0; i < grdToaTau.Rows.Count; i++) { // Add to count Column grdToaTau.Rows[i].Cells["Count"].Value = (i + 1).ToString(); var toaTau = (tblToaTau)grdToaTau.Rows[i].DataBoundItem; //if (_listToaTau.Any(tau => tau.tblChuyenTau.TrainID == toaTau.tblChuyenTau.TrainID)) //{ // grdToaTau.Rows[i].Cells["CusCheck"].Value = true; //} } }
private void setupDataGrid(DataGridView view, object dataSource) { // change the header color view.ColumnHeadersDefaultCellStyle.BackColor = Color.FromArgb(68, 101, 128); view.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; view.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; view.ColumnHeadersDefaultCellStyle.Font = new System.Drawing.Font(view.Font, FontStyle.Bold); view.EnableHeadersVisualStyles = false; // change the selection row color view.DefaultCellStyle.SelectionBackColor = Color.FromArgb(79, 169, 236); view.DefaultCellStyle.SelectionForeColor = Color.Black; // change the grid border style view.RowHeadersBorderStyle = DataGridViewHeaderBorderStyle.None; view.CellBorderStyle = DataGridViewCellBorderStyle.None; view.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; view.CellPainting += view_CellPainting; // attributes for the datagrid view.SelectionMode = DataGridViewSelectionMode.FullRowSelect; view.MultiSelect = true; view.RowHeadersVisible = false; view.AllowUserToDeleteRows = false; view.AllowUserToAddRows = false; view.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; // add checkbox header DataGridViewCheckBoxColumn chkbox = new DataGridViewCheckBoxColumn(); chkbox.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; DatagridViewCheckBoxHeaderCell chkHeader = new DatagridViewCheckBoxHeaderCell(); chkbox.HeaderCell = chkHeader; chkHeader.OnCheckBoxClicked += new CheckBoxClickedHandler(chkHeader_OnCheckBoxClicked); view.Columns.Add(chkbox); // set the data view.DataSource = dataSource; view.Columns[1].Visible = false; // hide the id of the database data }
private void frmYZ_Load(object sender, EventArgs e) { //App.FormStytleSet(this, true); //解决改版后表格中复选框无法选中(放到数据加载前) DatagridViewCheckBoxHeaderCell cbHeader = new DatagridViewCheckBoxHeaderCell(); cbHeader.OnCheckBoxClicked += new CheckBoxClickedHandler(cbHeader_OnCheckBoxClicked); longDgv.ReadOnly = false; foreach (DataGridViewColumn col in longDgv.Columns) { if (col.Name == "选择") { col.ReadOnly = false; } else { col.ReadOnly = true; } } btnOk_Click(sender, e); longDgv.SelectionMode = DataGridViewSelectionMode.FullRowSelect; ShortDgv.SelectionMode = DataGridViewSelectionMode.FullRowSelect; }
private void frmSendNotice_Load(object sender, EventArgs e) { lblQPeo.Text = App.UserAccount.UserInfo.User_name; lblQSec.Text = App.UserAccount.CurrentSelectRole.Role_name; lblNTime.Text = App.GetSystemTime().ToString("yyyy-MM-dd HH:mm"); lblSendee.Text = PatientInfo.Sick_Doctor_Name.ToString(); lblSendSec.Text = PatientInfo.Section_Name.ToString(); //自评、科室和院级都为环节质控 if (type == "E") { lblGrade.Text = "终末质控"; } else { lblGrade.Text = "环节质控"; } DataGridViewCheckBoxColumn colCB = new DataGridViewCheckBoxColumn(); colCB.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; DatagridViewCheckBoxHeaderCell cbHeader = new DatagridViewCheckBoxHeaderCell(); colCB.Name = "1"; colCB.HeaderCell = cbHeader; dgvObjective.Columns.Insert(0, colCB); cbHeader.OnCheckBoxClicked += new CheckBoxClickedHandler(cbHeader_OnCheckBoxClicked); dgvObjective.DataSource = dtObjective.DefaultView; dgvSubjective.DataSource = dtSubjective.DefaultView; for (int i = 0; i < dgvObjective.Columns.Count; i++) { if (dgvObjective.Columns[i].Name == "1") { dgvObjective.Columns[i].ReadOnly = false; dgvObjective.Columns[i].Width = 30; } else { dgvObjective.Columns[i].ReadOnly = true; dgvObjective.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; } } dgvObjective.Columns["项目编码"].Visible = false; try { //是否有上一次未反馈的整改信息 string strSql = "select id,CONTENT from T_AMENDMENTS_INFO t where (t.state_flag='0' or t.state_flag='1') and t.patient_id='" + PatientInfo.Id.ToString() + "' and t.receive_user_id='" + PatientInfo.Sick_Doctor_Id + "' and type='" + type + "'"; dtInfoOld = App.GetDataSet(strSql).Tables[0]; if (dtInfoOld.Rows.Count > 0) { string strMarkId = App.ReadSqlVal("select mark_id from t_quality_relation where key_id='" + dtInfoOld.Rows[0]["id"].ToString() + "'and flag='1'", 0, "mark_id"); if (!string.IsNullOrEmpty(strMarkId)) { foreach (DataGridViewRow Row in dgvObjective.Rows) { if (strMarkId.Contains("," + Row.Cells["项目编码"].Value.ToString() + ",")) { Row.Cells["1"].Value = true; } } } rtxRemarks.Text = dtInfoOld.Rows[0]["CONTENT"].ToString(); } } catch { } }
private void UpdateGridProcesados(List <TituloPdf> items) { DataGridProcesados.Columns.Clear(); // DataPropertyName = "IsProcesado", DataGridViewCheckBoxColumn chkbox = new DataGridViewCheckBoxColumn() { DataPropertyName = "IsProcesado", Width = 30, MinimumWidth = 30 }; DatagridViewCheckBoxHeaderCell chkHeader = new DatagridViewCheckBoxHeaderCell(); chkbox.HeaderCell = chkHeader; chkHeader.OnCheckBoxClicked += new CheckBoxClickedHandler(chkHeader_OnCheckBoxClicked); DataGridProcesados.Columns.Add(chkbox); //DataGridProcesados.Columns.Add(new DataGridViewCheckBoxColumn() { DataPropertyName = "IsProcesado", Width = 30, MinimumWidth = 30 }); DataGridProcesados.Columns.Add(new DataGridViewTextBoxColumn() { HeaderText = "Id", DataPropertyName = "IdTitulo", ReadOnly = true, Width = 45, MinimumWidth = 45 }); DataGridProcesados.Columns.Add(new DataGridViewTextBoxColumn() { HeaderText = "Nombre ", DataPropertyName = "NombreArchivo", ReadOnly = true }); DataGridProcesados.Columns.Add(new DataGridViewTextBoxColumn() { HeaderText = "Título", DataPropertyName = "DescripcionTitulo", ReadOnly = true }); DataGridProcesados.Columns.Add(new DataGridViewCheckBoxColumn() { HeaderText = "File?", DataPropertyName = "IsArchivoCopiado", ReadOnly = true, Width = 45 }); DataGridProcesados.Columns.Add(new DataGridViewTextBoxColumn() { HeaderText = "Mensaje Archivo", DataPropertyName = "MensajeCopia", ReadOnly = true }); DataGridProcesados.Columns.Add(new DataGridViewCheckBoxColumn() { HeaderText = "SQL?", DataPropertyName = "IsEjecutadoSQL", ReadOnly = true, Width = 45 }); DataGridProcesados.Columns.Add(new DataGridViewTextBoxColumn() { HeaderText = "Mensaje SQL", DataPropertyName = "MensajeSQL", ReadOnly = true }); DataGridProcesados.Columns.Add(new DataGridViewTextBoxColumn() { HeaderText = "PDF anterior", DataPropertyName = "UrlPdfAnterior", ReadOnly = true }); DataGridProcesados.Columns.Add(new DataGridViewTextBoxColumn() { HeaderText = "PDF nuevo", DataPropertyName = "UrlPdf", ReadOnly = true }); DataGridProcesados.Columns.Add(new DataGridViewTextBoxColumn() { HeaderText = "Edicion", DataPropertyName = "Edicion", ReadOnly = true }); DataGridProcesados.Columns.Add(new DataGridViewTextBoxColumn() { HeaderText = "Query", DataPropertyName = "Query", ReadOnly = true }); DataGridProcesados.CellClick -= DataGridProcesados_CellClick; DataGridProcesados.CellClick += DataGridProcesados_CellClick; this.DataGridProcesados.DataSource = items; foreach (DataGridViewRow item in DataGridProcesados.Rows) { var row = item.DataBoundItem as TituloPdf; if (row.IsSeleccionado) { item.Cells[0].Value = row.IsSeleccionado; } } }
/// <summary> /// 获取未审核的科室模板 /// </summary> private void GetTemplateListUnCheck() { dataGridViewX1.Columns.Clear(); string Sql = ""; //Sql = "select tid as 编号,tname as 名称,u1.user_name as 创建人,a.create_time 创建时间,a.sectionchek as 审核标记 ,a.mamagechek as 医务科审核 " + // "from t_tempplate a inner join t_account a2 on a2.account_id=a.creator_id " + // "inner join t_account_user a3 on a2.account_id=a3.account_id " + // "inner join t_userinfo u1 on a3.user_id=u1.user_id " + // "where tid in " + // "(select TEMPLATE_ID from t_tempplate_section c where c.section_id=" + // cboCusection.SelectedValue.ToString() + ")";//a.tempplate_level='S' and if (cboCusection.Text == "--请选择--" || cboCusection.SelectedIndex == -1) { Sql = "select tid as 编号,tname as 名称,u1.user_name as 创建人,a.create_time 创建时间,a.mamagechek as 医务科审核 " + "from t_tempplate a inner join t_account a2 on a2.account_id=a.creator_id " + "inner join t_account_user a3 on a2.account_id=a3.account_id " + "inner join t_userinfo u1 on a3.user_id=u1.user_id " + "where tid in " + "(select TEMPLATE_ID from t_tempplate_section c )"; } else { Sql = "select tid as 编号,tname as 名称,u1.user_name as 创建人,a.create_time 创建时间,a.mamagechek as 医务科审核 " + "from t_tempplate a inner join t_account a2 on a2.account_id=a.creator_id " + "inner join t_account_user a3 on a2.account_id=a3.account_id " + "inner join t_userinfo u1 on a3.user_id=u1.user_id " + "where tid in " + "(select TEMPLATE_ID from t_tempplate_section c where c.section_id=" + cboCusection.SelectedValue.ToString() + ")"; } string condions = ""; if (txtName.Text.Trim().Length > 0) { Sql += " and tname like '%" + txtName.Text.Trim() + "%' "; } if (App.UserAccount.CurrentSelectRole.Role_name == "医务科主任" || App.UserAccount.CurrentSelectRole.Role_name == "医务科副主任") { if (cboType.Text == "已审核") { condions = " and a.sectionchek='Y' and a.mamagechek='Y'"; } else if (cboType.Text == "未审核") { condions = " and (a.mamagechek='N' or a.mamagechek is null or a.sectionchek='N' or a.sectionchek is null) "; } } else { if (cboType.Text == "已审核") { condions = " and a.sectionchek='Y'"; } else if (cboType.Text == "未审核") { condions = " and (a.sectionchek='N' or a.sectionchek is null)"; } } Sql = Sql + " " + condions; DataSet ds = App.GetDataSet(Sql); dataGridViewX1.DataSource = ds.Tables[0].DefaultView; DataGridViewCheckBoxColumn newColumn = new DataGridViewCheckBoxColumn(); //解决改版后表格中复选框无法选中(放到数据加载前) DatagridViewCheckBoxHeaderCell cbHeader = new DatagridViewCheckBoxHeaderCell(); newColumn.HeaderCell = cbHeader; newColumn.Name = "1"; dataGridViewX1.Columns.Insert(0, newColumn); cbHeader.OnCheckBoxClicked += new CheckBoxClickedHandler(cbHeader_OnCheckBoxClicked); dataGridViewX1.ReadOnly = false; foreach (DataGridViewColumn col in dataGridViewX1.Columns) { if (col.Name == "1") { col.ReadOnly = false; } else { col.ReadOnly = true; } } //newColumn.HeaderText = "选择"; //dataGridViewX1.Columns.Insert(0, newColumn); //dataGridViewX1.Columns[0].ReadOnly = false; for (int i = 1; i < dataGridViewX1.Columns.Count; i++) { dataGridViewX1.Columns[i].ReadOnly = true; } RefleshRowColor(); dataGridViewX1.AutoResizeColumns(); //dataGridViewX1.Refresh(); }