Exemplo n.º 1
0
 private void ChangeCurrentNode(MyDGV0427 dgv)
 {
     SelectedNodes = new List <TNode>();
     if (dgv.SelectedRows.Count > 0)
     {
         SelectedNodes.Clear();
         foreach (DataGridViewRow row in dgv.SelectedRows)
         {
             var data = dgv.Rows[0].DataBoundItem as ITNodeData;// as BuildingSubsidenceDataV1;
             SelectedNodes.Add(Model.MemorableData.Data.Nodes.First(c => c.NodeCode == data.NodeCode));
         }
         return;
     }
     else if (dgv.SelectedCells.Count > 0)
     {
         List <int> rowIndexes = new List <int>();
         foreach (DataGridViewCell cell in dgv.SelectedCells)
         {
             if (!rowIndexes.Contains(cell.RowIndex))
             {
                 rowIndexes.Add(cell.RowIndex);
             }
         }
         foreach (var rowIndex in rowIndexes)
         {
             var data = dgv.Rows[rowIndex].DataBoundItem as ITNodeData;// as BuildingSubsidenceDataV1;
             SelectedNodes.Add(Model.MemorableData.Data.Nodes.First(c => c.NodeCode == data.NodeCode));
         }
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 保存列表选中项,由于采用了模态形式,页面显示总是刷新掉选中项
 /// </summary>
 void SaveDataGridViewSelection(MyDGV0427 dgv, List <int> rows, List <CellLocation> cells)
 {
     rows.Clear();
     foreach (DataGridViewRow row in dgv.SelectedRows)
     {
         rows.Add(row.Index);
     }
     cells.Clear();
     if (dgv.SelectedCells.Count > 0)
     {
         cells.Add(new CellLocation(dgv.SelectedCells[0].RowIndex, dgv.SelectedCells[0].ColumnIndex));
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// 加载列表选中项
 /// </summary>
 void LoadDataGridViewSelection(MyDGV0427 dgv, List <int> rows, List <CellLocation> cells)
 {
     if (rows.Count() > 0)
     {
         foreach (int rowIndex in rows)
         {
             dgv.Rows[rowIndex].Selected = true;
         }
     }
     if (cells.Count() > 0)
     {
         //2017/05/09 10:05 修正Cells的选中,CurrentCell是左侧箭头的设置
         foreach (CellLocation cell in cells)
         {
             dgv.Rows[cell.RowIndex].Cells[cell.ColumnIndex].Selected = true;
         }
         dgv.CurrentCell = dgv[cells[0].ColumnIndex, cells[0].RowIndex];
     }
 }
Exemplo n.º 4
0
 void ClearDataGridViewSelection(MyDGV0427 dgv, List <int> rows, List <CellLocation> cells)
 {
     rows.Clear();
     cells.Clear();
 }