/// <summary> /// 重绘标准偏差文字行 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DGW_FA_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) { // 对第1列相同单元格进行合并 if (e.RowIndex == _intPcRpw && e.ColumnIndex >= 0) { using ( Brush gridBrush = new SolidBrush(this.DGW_FA.GridColor), backColorBrush = new SolidBrush(e.CellStyle.BackColor) ) { using (Pen gridLinePen = new Pen(gridBrush)) { // 清除单元格 e.Graphics.FillRectangle(backColorBrush, e.CellBounds); // 画 Grid 边线(仅画单元格的底边线) if (e.ColumnIndex < DGW_FA.Columns.Count) { e.Graphics.DrawLine(gridLinePen, e.CellBounds.Left, e.CellBounds.Bottom - 1, e.CellBounds.Right - 1, e.CellBounds.Bottom - 1); } if (e.ColumnIndex == DGW_FA.Columns.Count - 1) { e.Graphics.DrawLine(gridLinePen, e.CellBounds.Right - 1, e.CellBounds.Top, e.CellBounds.Right - 1, e.CellBounds.Bottom); } e.Handled = true; } } } DGW_FA.ClearSelection(); }
/// <summary> /// 方案项目选择,左键 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DGW_FA_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0) { DGW_FA.ClearSelection(); return; } if (_Glfx == 0) { MessageBoxEx.Show(this, "请先选择功率方向后再进行方案配置...", "配置错误", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (e.ColumnIndex < 0 || e.RowIndex < 0 || e.RowIndex == _intPcRpw) { return; } //if (DGW_FA.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor == Color.DarkGreen) if (IsSelect(DGW_FA.Rows[e.RowIndex].Cells[e.ColumnIndex])) { //DGW_FA.DefaultCellStyle.SelectionBackColor = Color.White; //DGW_FA.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor = Color.White; SelectPoint(DGW_FA.Rows[e.RowIndex].Cells[e.ColumnIndex], false); PointCountChange(sender, _PointCount--); //移除数量-- string _PrjID = string.Format("{0}{1:D}{2:D}{3}{4}00" , ((e.RowIndex / (float)_intPcRpw) < 1 ? "1" : "2") , (int)_Glfx , (int)_Yj , DGW_FA.Rows[e.RowIndex].HeaderCell.Tag.ToString() , DGW_FA.Columns[e.ColumnIndex].Tag.ToString()); ((CLDC_DataCore.Model.Plan.Plan_WcPoint) this.Tag).RemovePoint(_PrjID); //移除一个点 } else { //DGW_FA.DefaultCellStyle.SelectionBackColor = Color.DarkGreen; //DGW_FA.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor = Color.DarkGreen; SelectPoint(DGW_FA.Rows[e.RowIndex].Cells[e.ColumnIndex], true); PointCountChange(sender, _PointCount++); //选中数量++ ((CLDC_DataCore.Model.Plan.Plan_WcPoint) this.Tag).Add((CLDC_Comm.Enum.Cus_WcType) int.Parse((e.RowIndex / (float)_intPcRpw) < 1 ? "1" : "2") , _Glfx , _Yj , DGW_FA.Rows[e.RowIndex].HeaderCell.Value.ToString() , DGW_FA.Columns[e.ColumnIndex].HeaderCell.Value.ToString() , 0 , 0); //增加一个点 } DGW_FA.Refresh(); }