public static void EnableClipboardCopy(this SuperGridControl control) { control.KeyDown += (s, e) => { //Copy if (!e.Control || e.KeyCode != Keys.C) { return; } e.SuppressKeyPress = true; var panel = ((SuperGridControl)s).PrimaryGrid; var groupBy = panel.GetSelectedCells().GroupBy(_ => ((GridCell)_).RowIndex); var selectedText = string.Join("\n", groupBy.Select(groupCell => string.Join("\t", groupCell.Select(v => ((GridCell)v).Value.ToString()).ToArray())).ToArray()); if (!string.IsNullOrEmpty(selectedText)) { Clipboard.SetText(selectedText); } Debug.WriteLine(panel.SelectedCellCount); }; }
private void BindGD_YF(SuperGridControl superGridControl, string gd) { string sql = string.Format(@"select t2.id batchid, t5.ordernum,t5.trainnumber,t5.carmodel,t5.PASSTIME,case when t6.isdischarged=1 then '已翻车' else '未翻车' end IsFC,t1.GROSSQTY,t1.SKINQTY,t1.SUTTLEQTY,'' as SampleCode from cmcstbtraincarriagepass t5 left join fultbtransport t1 on t1.pkid=t5.id left join fultbinfactorybatch t2 on t1.infactorybatchid=t2.id inner join cmcstbtransportposition t6 on t5.id=t6.transportid where t6.tracknumber='{0}' and t5.passtime>sysdate-1 order by t5.passtime desc,t5.ordernum desc " , gd); DataTable list = commonDAO.SelfDber.ExecuteDataTable(sql); for (int i = 0; i < list.Rows.Count; i++) { if (list.Rows[i]["batchid"] != DBNull.Value) { string sql1 = string.Format(@"select SampleCode from cmcstbrcsampling t1 where t1.infactorybatchid='{0}' and t1.samplecode not like 'CYCC%'", list.Rows[i]["batchid"].ToString()); DataTable dt = commonDAO.SelfDber.ExecuteDataTable(sql1); if (dt != null && dt.Rows.Count > 0) { list.Rows[i]["SampleCode"] = dt.Rows[0]["SampleCode"]; } } } superGridControl.PrimaryGrid.DataSource = list; }
/// <summary> /// 选中皮带采样码一致的记录 /// </summary> /// <param name="superGridControl"></param> /// <param name="equInfSampleBarrel"></param> private void CheckedSameBarrelRow(SuperGridControl superGridControl, InfEquInfSampleBarrel equInfSampleBarrel) { if (equInfSampleBarrel == null) { return; } if (string.IsNullOrWhiteSpace(equInfSampleBarrel.SampleCode)) { return; } this.currentEquInfSampleBarrels.Clear(); this.currentSampleCode = equInfSampleBarrel.SampleCode; this.currentEquInfSampleBarrels.Add(equInfSampleBarrel); foreach (GridRow gridRow in superGridControl.PrimaryGrid.Rows) { InfEquInfSampleBarrel thisEquInfSampleBarrel = gridRow.DataItem as InfEquInfSampleBarrel; if (thisEquInfSampleBarrel == null || thisEquInfSampleBarrel.Id == equInfSampleBarrel.Id) { continue; } gridRow.Checked = (thisEquInfSampleBarrel != null && !string.IsNullOrWhiteSpace(thisEquInfSampleBarrel.SampleCode) && thisEquInfSampleBarrel.SampleCode == equInfSampleBarrel.SampleCode && thisEquInfSampleBarrel.BarrelType == equInfSampleBarrel.BarrelType); if (gridRow.Checked) { this.currentEquInfSampleBarrels.Add(thisEquInfSampleBarrel); } } }
public static void SaveDataToFile(this SuperGridControl ctl, string filePath) { if (string.IsNullOrEmpty(filePath)) { return; } if (ctl == null || ctl.PrimaryGrid.Rows.Count < 1) { return; } string dir = Path.GetDirectoryName(filePath); if (string.IsNullOrEmpty(dir)) { return; } if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } ctl.PrimaryGrid.SelectAll(); ctl.PrimaryGrid.CopySelectedCellsToClipboard(true); string str = Clipboard.GetText(TextDataFormat.Text); File.AppendAllText(filePath, str); }
public static void FullScreenGridControlInWidth(this SuperGridControl ctl) { /**************************计算公式**********************************************/ /* 单元格宽度 = (总可用宽度)/ 列数 */ /******************************计算公式******************************************/ if (ctl == null || ctl.PrimaryGrid.Columns.Count <= 0) { return; } int count = ctl.PrimaryGrid.Columns.Count; int totalWidth = 0; //可使用的宽度 if (ctl.VScrollBarVisible) { totalWidth = ctl.Width - System.Windows.Forms.SystemInformation.VerticalScrollBarWidth; } else { totalWidth = ctl.Width; } if (ctl.PrimaryGrid.ShowRowHeaders) { totalWidth = totalWidth - ctl.PrimaryGrid.RowHeaderWidth; } int widthUnit = totalWidth / count; for (int i = 0; i < count - 1; i++) { ctl.PrimaryGrid.Columns[i].Width = widthUnit; } ctl.PrimaryGrid.Columns[count - 1].Width = totalWidth - (count - 1) * widthUnit; //最后一列占据剩余的宽度 }
private void superGridControl1_CellMouseDown(object sender, GridCellMouseEventArgs e) { if (e.GridCell.ColumnIndex == -1 || e.GridCell.GridRow.Index == -1) { return; } SuperGridControl sgc = (SuperGridControl)sender; var Cell = sgc.PrimaryGrid.GetCell(e.GridCell.GridRow.Index, 12); string id = Cell != null?Cell.Value.ToString() : ""; CmcsBuyFuelTransport entity = Dbers.GetInstance().SelfDber.Get <CmcsBuyFuelTransport>(id); if (entity == null) { return; } String newid = id.ToString(); switch (sgc.PrimaryGrid.GetCell(e.GridCell.GridRow.Index, e.GridCell.ColumnIndex).NullString) { case "抓拍": break; case "装车线": break; } }
private void buttonX6_Click(object sender, EventArgs e) { try { if (string.IsNullOrWhiteSpace(comboObjednavka.Text)) { MessageBox.Show("Najprv zadaj Objednávku"); return; } if (string.IsNullOrWhiteSpace(comboBoxEx1.Text)) { MessageBox.Show("Najprv zadaj Zákazku"); return; } string connectionString = Class1.dbs_nastavenia("DBS_connection_string"); SqlConnection sqlConn = new SqlConnection(connectionString); sqlConn.Open(); SuperGridControl superGridControl1 = Parent.Parent.Controls.Find("superGridControl1", true).FirstOrDefault() as SuperGridControl; superGridControl1.PrimaryGrid.EnableFiltering = true; superGridControl1.PrimaryGrid.EnableColumnFiltering = true; superGridControl1.PrimaryGrid.EnableRowFiltering = true; superGridControl1.PrimaryGrid.Columns[1].EnableFiltering = Tbool.True; superGridControl1.PrimaryGrid.Columns[1].ShowPanelFilterExpr = Tbool.True; superGridControl1.PrimaryGrid.Columns[1].FilterExpr = "[CisloZakazky] = " + comboBoxEx1.Text + " & [Objednavka] = '" + comboObjednavka.Text + "/" + PoradoveCislo.Text + "' & [Rework] = " + txtRework.Text; Class1.update_grid_konektorovanie(ParentForm, true); sqlConn.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// 绑定采样信息 /// </summary> /// <param name="superGridControl"></param> /// <param name="machineCode">设备编码</param> private void BindSampling(SuperGridControl superGridControl, string machinecode, string samplecode) { string sql = string.Format(@"SELECT T1.SAMPLECODE,T2.CARNUMBER,T2.CARMODEL,T2.ORDERNUMBER,T2.CYCOUNT,T1.TRAINCODE,T2.STARTTIME,T2.ENDTIME,'' STATUS FROM INFTBBELTSAMPLEPLANDETAIL T2 LEFT JOIN INFTBBELTSAMPLEPLAN T1 ON T2.PLANID=T1.ID WHERE T1.MACHINECODE='{0}' AND T1.SAMPLECODE='{1}' ORDER BY T2.ORDERNUMBER " , machinecode, samplecode); DataTable list = commonDAO.SelfDber.ExecuteDataTable(sql); for (int i = 0; i < list.Rows.Count; i++) { DateTime s = Convert.ToDateTime(list.Rows[i]["starttime"]); DateTime e = Convert.ToDateTime(list.Rows[i]["endtime"]); if (s.Year < 2000) { list.Rows[i]["status"] = "待采样"; } else if (s.Year > 2000 && e.Year < 2000) { list.Rows[i]["status"] = "正在采样"; } else if (e.Year > 2000) { list.Rows[i]["status"] = "已采样"; } } superGridControl.PrimaryGrid.DataSource = list; }
public void llena_superGrid_con(String consulta, SuperGridControl super_grid) { DataSet data_set = new DataSet(); dame_dataset_de(consulta, data_set); super_grid.PrimaryGrid.DataSource = data_set; }
public void ExportarDataGridViewExcel(ref Excel.Worksheet hoja_trabajo, SuperGridControl grd, string nombreCabecera) { Excel.Range rango; int i = 0; //Recorremos el DataGridView rellenando la hoja de trabajo int k = 6 + 64; char columF = (char)k; int fila2 = i + 8; string filaBorde = fila2.ToString(); char columI = 'A'; //Ponemos borde a las celdas rango = hoja_trabajo.Range[columI + fila2.ToString(), columF + fila2.ToString()]; rango.Borders.LineStyle = Excel.XlLineStyle.xlContinuous; rango.Style.Font.Bold = false; hoja_trabajo.Cells[8, 1] = cambio.LaptopNuevo.Codigo; hoja_trabajo.Cells[8, 2] = cambio.LaptopNuevo.Modelo.NombreMarca; hoja_trabajo.Cells[8, 3] = cambio.LaptopNuevo.Modelo.NombreModelo; string aux = ""; aux = cambio.LaptopNuevo.Procesador.Modelo.NombreModelo + "/GEN" + cambio.LaptopNuevo.Procesador.Generacion.ToString(); hoja_trabajo.Cells[8, 4] = aux; hoja_trabajo.Cells[8, 5] = cambio.LaptopNuevo.Video.Capacidad.ToString() + " GB"; hoja_trabajo.Cells[8, 6] = cambio.LaptopNuevo.TamanoPantalla.ToString(); montaCabeceras(1, ref hoja_trabajo, grd, nombreCabecera); }
public static DataTable DgvToTable(SuperGridControl dgv, string name) { DataTable dt = new DataTable { TableName = name }; // 列强制转换 foreach (GridColumn column in dgv.PrimaryGrid.Columns) { if (!column.Visible) { continue; } DataColumn dc = new DataColumn(column.Name); dt.Columns.Add(dc); } foreach (GridRow row in dgv.PrimaryGrid.Rows) { var dr = dt.NewRow(); foreach (GridColumn column in dgv.PrimaryGrid.Columns) { if (!column.Visible) { continue; } dr[column.Name] = Convert.ToString(row.Cells[column].Value); } dt.Rows.Add(dr); } return(dt); }
private void superGridControl1_GetCellFormattedValue(object sender, GridGetCellFormattedValueEventArgs e) { if (e.GridCell.ColumnIndex == -1 || e.GridCell.GridRow.Index == -1) { return; } SuperGridControl sgc = (SuperGridControl)sender; String newid = sgc.PrimaryGrid.GetCell(e.GridCell.GridRow.Index, 13).Value.ToString(); switch (sgc.PrimaryGrid.GetCell(e.GridCell.GridRow.Index, e.GridCell.ColumnIndex).NullString) { case "抓拍": if (Dbers.GetInstance().SelfDber.Entities <CmcsTrainWatch>(String.Format(" where TrainWeightRecordId='{0}'", newid)).Count == 0) { sgc.PrimaryGrid.GetCell(e.GridCell.GridRow.Index, e.GridCell.ColumnIndex).Value = ""; } break; case "装车线": if (Dbers.GetInstance().SelfDber.Entities <CmcsTrainLine>(String.Format(" where TrainWeightRecordId='{0}'", newid)).Count == 0) { sgc.PrimaryGrid.GetCell(e.GridCell.GridRow.Index, e.GridCell.ColumnIndex).Value = ""; } break; } }
public void ExportarDataGridViewExcel(ref Excel.Worksheet hoja_trabajo, SuperGridControl grd, string nombreCabecera) { Excel.Range rango; int i = 0; //Recorremos el DataGridView rellenando la hoja de trabajo foreach (DevolucionDetalle det in devolucion.Detalles) { //int k = grd.Columns.Count + 64; int k = 6 + 64; char columF = (char)k; int fila2 = i + 8; string filaBorde = fila2.ToString(); char columI = 'A'; //Ponemos borde a las celdas rango = hoja_trabajo.Range[columI + fila2.ToString(), columF + fila2.ToString()]; rango.Borders.LineStyle = Excel.XlLineStyle.xlContinuous; rango.Style.Font.Bold = false; hoja_trabajo.Cells[i + 8, 1] = "LAPTOP " + det.CodigoLC; hoja_trabajo.Cells[i + 8, 2] = det.MarcaLC; hoja_trabajo.Cells[i + 8, 3] = det.ModeloLC; hoja_trabajo.Cells[i + 8, 4] = det.Observacion; hoja_trabajo.Cells[i + 8, 5] = (det.Cobrar == 1) ? "Pagará Cliente" : "No Pagará Cliente"; hoja_trabajo.Cells[i + 8, 6] = (det.Danado == 1) ? "Equipo Dañado" : "Equipo Sin Daño"; i++; } montaCabeceras(1, ref hoja_trabajo, grd, nombreCabecera); }
public void llena_detalle_tratamiento(String codigo, String consultorio, SuperGridControl grid_medicos, SuperGridControl grid_mtos) { String consulta_m = consultas[G_MED] + " WHERE NUMERO_CONSULTORIO=" + consultorio; SPG.llena_superGrid_con(consulta_m, grid_medicos); llena_detalle("MXTC", codigo, grid_mtos); }
/// <summary> /// 根据批次Id加载采样单列表 /// </summary> /// <param name="superGridControl"></param> /// <param name="batchId"></param> private void LoadRCSamplingList(SuperGridControl superGridControl, string batchId) { this.CurrentRCSampling = null; List <CmcsRCSampling> list = commonDAO.GetSamplings(batchId); superGridControl.PrimaryGrid.DataSource = list; }
private void BindRCSampling(SuperGridControl superGridControl) { //List<View_CCSampling> list = beltSamplerDAO.GetViewCCSampling("where SamplingDate like '%" + DateTime.Now.ToString("yyyy-MM-dd") + "%'"); //superGridControl.PrimaryGrid.DataSource = list; List <View_RCSampling> list = beltSamplerDAO.GetViewRCSampling("where trunc(SamplingDate)>=trunc(:SamplingDate) and (infactorytype like '%出场' or infactorytype like '%销售%') order by SamplingDate", new { SamplingDate = DateTime.Now.AddDays(-3).Date }); superGridControl.PrimaryGrid.DataSource = list; }
public static void GenerateColumnFromClassWithDefaultEditor(this SuperGridControl ctl, Type target, int readonlyCol = 0) { if (ctl == null || target == null) { return; } ctl.PrimaryGrid.Columns.Clear(); PropertyInfo[] classPropertyInfo; classPropertyInfo = target.GetProperties(BindingFlags.Public | BindingFlags.Instance);//获得属性名 if (classPropertyInfo == null || classPropertyInfo.Length < 1) { return; } string catKey = ""; string editorType = ""; for (int i = 0; i < classPropertyInfo.Length; i++) { Type t = classPropertyInfo[i].PropertyType; // t will be System.String editorType = t.ToString(); object[] objs = classPropertyInfo[i].GetCustomAttributes(typeof(DescriptionAttribute), true); if (objs != null && objs.Length > 0) { catKey = ((DescriptionAttribute)objs[0]).Description; if (string.IsNullOrEmpty(catKey)) { catKey = string.Format("列{0}", i + 1); } //continue; GridColumn col = new GridColumn(catKey); if (i == readonlyCol) { col.ReadOnly = true; } col.DataPropertyName = classPropertyInfo[i].Name; if (editorType == "System.Boolean") { col.EditorType = typeof(GridCheckBoxXEditControl); } else if (editorType == "System.Int32") { col.EditorType = typeof(GridNumericUpDownEditControl); } else if (editorType == "System.Single") { col.EditorType = typeof(GridDoubleInputEditControl); } else { col.EditorType = typeof(GridTextBoxXEditControl); } ctl.PrimaryGrid.Columns.Add(col); } } }
private void superGridControl1_RowHeaderClick(object sender, GridRowHeaderClickEventArgs e) { if (e.GridRow.Index == -1) { return; } e.GridRow.IsSelected = true; SuperGridControl supergridcontrol = (SuperGridControl)sender; Id = supergridcontrol.GetCell(e.GridRow.RowIndex, 11).Value.ToString(); }
/// <summary> /// 加载今日已录入化验数据 /// </summary> /// <param name="superGridControl"></param> private void LoadBalanceList(SuperGridControl superGridControl) { List <InfBalanceRecord> list = commonDAO.SelfDber.Entities <InfBalanceRecord>("where trunc(OperDate)=trunc(sysdate) and MachineCode=:MachineCode order by CreateDate asc", new { MachineCode = this.MachineCode }); superGridControl.PrimaryGrid.DataSource = list; if (list == null || list.Count == 0) { return; } this.CurrentAssay = list[0]; }
public static void SetRowHeight(this SuperGridControl ctl, int rowHeight, int font) { if (ctl == null || ctl.PrimaryGrid.Columns.Count <= 0) { return; } for (int i = 0; i < ctl.PrimaryGrid.Columns.Count; i++) { ctl.PrimaryGrid.Columns[i].CellStyles.Default.Font = new System.Drawing.Font("Times New Roman", font); } ctl.PrimaryGrid.MinRowHeight = rowHeight; }
private void ClearStyles(SuperGridControl sgrid) { GridPanel panel = sgrid.PrimaryGrid; foreach (GridRow row in panel.Rows) { foreach (GridCell cell in row.Cells) { cell.CellStyles.Default = null; } } }
private void superGridControl1_CellMouseDown(object sender, GridCellMouseEventArgs e) { if (e.GridCell.GridRow.Index == -1) { return; } e.GridCell.GridRow.IsSelected = true; SuperGridControl supergridcontrol = (SuperGridControl)sender; Id = supergridcontrol.GetCell(e.GridCell.GridRow.RowIndex, 11).Value.ToString(); createinfo(); }
/// <summary> /// 设置单元格字体颜色 /// <para>可用于设置执行结果是否成功的指示</para> /// </summary> /// <param name="ctl">SuperGridControl</param> /// <param name="row">行</param> /// <param name="col">列</param> /// <param name="color">颜色</param> public static void SetCellForeColor(this SuperGridControl ctl, int row, int col, System.Drawing.Color color) { if (ctl == null || ctl.PrimaryGrid.Columns.Count < 1 || ctl.PrimaryGrid.Rows.Count < 1) { return; } if (row >= ctl.PrimaryGrid.Rows.Count || col >= ctl.PrimaryGrid.Columns.Count) { return; } GridRow targetRow = ctl.PrimaryGrid.Rows[row] as GridRow; targetRow.Cells[col].CellStyles.Default.TextColor = color; }
public static GridColumn CreateColumn(this SuperGridControl control, string name, string text, int width = 50, Alignment alignment = Alignment.MiddleLeft) { var grid = control.PrimaryGrid; var col = new GridColumn(name) { Width = width, HeaderText = text }; col.CellStyles.Default.Alignment = alignment; grid.Columns.Add(col); return(col); }
private void buttonX6_Click(object sender, EventArgs e) { try { if (string.IsNullOrWhiteSpace(comboObjednavka.Text)) { MessageBox.Show("Najprv zadaj Objednávku"); return; } if (string.IsNullOrWhiteSpace(comboBoxEx1.Text)) { MessageBox.Show("Najprv zadaj Zákazku"); return; } if (string.IsNullOrWhiteSpace(textBoxX1.Text)) { MessageBox.Show("Nenapísala si počet mriežok, nemôžem vytvoriť tabuľku"); return; } string connectionString = Class1.dbs_nastavenia("DBS_connection_string"); SqlConnection sqlConn = new SqlConnection(connectionString); sqlConn.Open(); for (int i = 1; i <= Convert.ToInt32(this.textBoxX1.Text); i++) { SqlCommand sqlCommKonektorovanie = new SqlCommand(); sqlCommKonektorovanie = sqlConn.CreateCommand(); sqlCommKonektorovanie.CommandText = @"INSERT INTO tblKonektorovanie (CisloZakazky,Objednavka,FBGnr,rework) VALUES (@CisloZakazky,@Objednavka,@FBGnr,@rework)"; sqlCommKonektorovanie.Parameters.Add(new SqlParameter("@CisloZakazky", SqlDbType.Int)).Value = comboBoxEx1.Text; sqlCommKonektorovanie.Parameters.Add(new SqlParameter("@Objednavka", SqlDbType.NVarChar, 50)).Value = comboObjednavka.Text + "/" + PoradoveCislo.Text; sqlCommKonektorovanie.Parameters.Add(new SqlParameter("@FBGnr", SqlDbType.NChar, 10)).Value = i; sqlCommKonektorovanie.Parameters.Add(new SqlParameter("@rework", SqlDbType.NChar, 10)).Value = txtRework.Text; sqlCommKonektorovanie.ExecuteNonQuery(); } SuperGridControl superGridControl1 = Parent.Parent.Controls.Find("superGridControl1", true).FirstOrDefault() as SuperGridControl; superGridControl1.PrimaryGrid.EnableFiltering = true; superGridControl1.PrimaryGrid.EnableColumnFiltering = true; superGridControl1.PrimaryGrid.EnableRowFiltering = true; superGridControl1.PrimaryGrid.Columns[1].EnableFiltering = Tbool.True; superGridControl1.PrimaryGrid.Columns[1].ShowPanelFilterExpr = Tbool.True; superGridControl1.PrimaryGrid.Columns[1].FilterExpr = "[CisloZakazky] = " + comboBoxEx1.Text + " & [Objednavka] = '" + comboObjednavka.Text + "/" + PoradoveCislo.Text + "' & [Rework] = " + txtRework.Text; Class1.update_grid_konektorovanie(ParentForm, true); sqlConn.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// Adds default data to the supplied grid /// </summary> /// <param name="grid"></param> private void AddDefaultData(SuperGridControl grid) { GridPanel panel = grid.PrimaryGrid; for (int i = 0; i < 10; i++) { Employee emp = Employee.GetNewEmployee(); GridRow row = new GridRow(emp.LastName, emp.FirstName, emp.Age, emp.Id); panel.Rows.Add(row); } }
public static void GenerateColumnFromClass(this SuperGridControl ctl, Type target) { /*****************************反射生成各列*******************************************/ /* 根据类的属性/属性/属性生成SuperGridControl的列 */ /* 列名为属性的Description Attribute */ /* 是否显示为列根据属性的Browsable Attribute */ /* 根据类的属性/属性/属性生成SuperGridControl的列 */ /*****************************反射生成各列*******************************************/ if (ctl == null || target == null) { return; } ctl.PrimaryGrid.Columns.Clear(); PropertyInfo[] classPropertyInfo; classPropertyInfo = target.GetProperties(BindingFlags.Public | BindingFlags.Instance);//获得属性名 if (classPropertyInfo == null || classPropertyInfo.Length < 1) { return; } string catKey = ""; for (int i = 0; i < classPropertyInfo.Length; i++) { object[] objs = classPropertyInfo[i].GetCustomAttributes(typeof(DescriptionAttribute), true); object[] objs1 = classPropertyInfo[i].GetCustomAttributes(typeof(BrowsableAttribute), true); //根据BrowsableAttribute判断是否显示为列 bool visible = true; if (objs != null && objs.Length > 0) { if (objs1 != null && objs1.Length > 0) { visible = ((BrowsableAttribute)objs1[0]).Browsable; } if (visible) { catKey = ((DescriptionAttribute)objs[0]).Description; if (string.IsNullOrEmpty(catKey)) { catKey = string.Format("列{0}", i + 1); //设置默认列名 } GridColumn col = new GridColumn(catKey); col.DataPropertyName = classPropertyInfo[i].Name; //设置绑定的信号属性 col.ColumnSortMode = ColumnSortMode.None; //禁止排序 col.ResizeMode = ColumnResizeMode.None; //禁止用户调整宽度 col.CellStyles.Default.Alignment = DevComponents.DotNetBar.SuperGrid.Style.Alignment.MiddleCenter; //单元格内容居中显示 ctl.PrimaryGrid.Columns.Add(col); } } } }
/// <summary> /// 选中采样码一致的记录 /// </summary> /// <param name="superGridControl"></param> /// <param name="sampleCode">采样码</param> private void CheckedSameBarrelRow(SuperGridControl superGridControl, string sampleCode) { currentEquInfSampleBarrels.Clear(); this.currentSampleCode = sampleCode; foreach (GridRow gridRow in superGridControl.PrimaryGrid.Rows) { CmcsEquInfSampleBarrel cmcsEquInfSampleBarrel = gridRow.DataItem as CmcsEquInfSampleBarrel; gridRow.Checked = (cmcsEquInfSampleBarrel != null && !string.IsNullOrWhiteSpace(cmcsEquInfSampleBarrel.SampleCode) && !string.IsNullOrWhiteSpace(sampleCode) && cmcsEquInfSampleBarrel.SampleCode == sampleCode); if (gridRow.Checked) { currentEquInfSampleBarrels.Add(cmcsEquInfSampleBarrel); } } }
private void superGridControl1_CellMouseDown(object sender, GridCellMouseEventArgs e) { if (e.GridCell.ColumnIndex == -1 || e.GridCell.GridRow.Index == -1) { return; } SuperGridControl sgc = (SuperGridControl)sender; CmcsTrainWeightRecord entity = Dbers.GetInstance().SelfDber.Get <CmcsTrainWeightRecord>(sgc.PrimaryGrid.GetCell(e.GridCell.GridRow.Index, 13).Value.ToString()); if (entity == null) { return; } String newid = sgc.PrimaryGrid.GetCell(e.GridCell.GridRow.Index, 13).Value.ToString(); switch (sgc.PrimaryGrid.GetCell(e.GridCell.GridRow.Index, e.GridCell.ColumnIndex).NullString) { case "抓拍": if (Dbers.GetInstance().SelfDber.Entities <CmcsTrainWatch>(String.Format(" where TrainWeightRecordId='{0}'", newid)).Count > 0) { FrmWeightBridgeLoad_Pic frm1 = new FrmWeightBridgeLoad_Pic(newid); if (frm1.ShowDialog() == DialogResult.OK) { } } else { } break; case "装车线": if (Dbers.GetInstance().SelfDber.Entities <CmcsTrainLine>(String.Format(" where TrainWeightRecordId='{0}'", newid)).Count > 0) { FrmWeightBridgeLoad_Line frm = new FrmWeightBridgeLoad_Line(newid); if (frm.ShowDialog() == DialogResult.OK) { } } else { } break; } }
public static void SetRowBackColor(this SuperGridControl ctrl, int row) { if (ctrl == null || ctrl.PrimaryGrid.Rows.Count < 1 || row > ctrl.PrimaryGrid.Rows.Count) { return; } int count = ctrl.PrimaryGrid.Rows.Count; if (row < 0) { for (int i = 0; i < count; i++) { GridRow currentRow = ctrl.PrimaryGrid.Rows[i] as GridRow; currentRow.CellStyles.Default.Background.Color1 = Color.White; currentRow.CellStyles.Default.Background.Color2 = Color.White; } } else if (row < ctrl.PrimaryGrid.Rows.Count) { for (int i = 0; i <= row; i++) { GridRow currentRow = ctrl.PrimaryGrid.Rows[i] as GridRow; if (i < row) { currentRow.CellStyles.Default.Background.Color1 = Color.LightGray; currentRow.CellStyles.Default.Background.Color2 = Color.LightGray; } else { currentRow.CellStyles.Default.Background.Color1 = Color.Green; currentRow.CellStyles.Default.Background.Color2 = Color.Green; } } } else { for (int i = 0; i <= row - 1; i++) { GridRow currentRow = ctrl.PrimaryGrid.Rows[i] as GridRow; currentRow.CellStyles.Default.Background.Color1 = Color.LightGray; currentRow.CellStyles.Default.Background.Color2 = Color.LightGray; } } }