当前位置: 首页>>代码示例>>C#>>正文


C# DataGridViewRow.Clone方法代码示例

本文整理汇总了C#中System.Windows.Forms.DataGridViewRow.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# DataGridViewRow.Clone方法的具体用法?C# DataGridViewRow.Clone怎么用?C# DataGridViewRow.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.DataGridViewRow的用法示例。


在下文中一共展示了DataGridViewRow.Clone方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CopySelectedRow

        public static void CopySelectedRow(DataGridViewPersistent dgv_org, DataGridViewRow row)
        {
            DataGridViewPersistent dgv_copy = new DataGridViewPersistent();

            try
            {
                if (dgv_copy.Columns.Count == 0)
                {
                    foreach (DataGridViewColumn dgvc in dgv_org.Columns)
                    {
                        dgv_copy.Columns.Add(dgvc.Clone() as DataGridViewColumn);
                    }
                }

                row = (DataGridViewRow)row.Clone();
                row.Cells[0].Value = row.Cells[0].Value;
                dgv_copy.Rows.Add(row);

                dgv_copy.AllowUserToAddRows = false;
                dgv_copy.Refresh();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
开发者ID:haoye1985,项目名称:Oasis-V1.2,代码行数:27,代码来源:DataGridViewHelper.cs

示例2: CloneWithValues

 /* CopyRow_Click
  * insert a copy of the current row at the next row  at the Matrix Script
  */
 public DataGridViewRow CloneWithValues(DataGridViewRow row)
 {
     DataGridViewRow clonedRow = (DataGridViewRow)row.Clone();
     for (Int32 index = 0; index < row.Cells.Count; index++)
     {
         clonedRow.Cells[index].Value = row.Cells[index].Value;
     }
     return clonedRow;
 }
开发者ID:surejm,项目名称:MatrixSkripter,代码行数:12,代码来源:Form1.cs

示例3: CopyRowWithValues

        public DataGridViewRow CopyRowWithValues(DataGridView Gridview, DataGridViewRow row, string[] ColumnNameTobeIgnoreValues)
        {
            DataGridViewRow copiedRow = (DataGridViewRow)row.Clone();

            for (Int32 index = 0; index < row.Cells.Count; index++)
            {
                string columnName = Gridview.Columns[index].Name.ToString().Trim();

                if (ColumnNameTobeIgnoreValues.Contains(columnName) == false)
                {
                    copiedRow.Cells[index].Value = row.Cells[index].Value;
                }
            }
            return copiedRow;
        }
开发者ID:anthanhcong,项目名称:atc-demand-instruction-form,代码行数:15,代码来源:P_003_KeHoachSXTheoLine_Event.cs

示例4: CloneRow

        /// <summary>
        /// Clones the row.
        /// </summary>
        /// <param name="row">The Data Grid View row.</param>
        /// <returns>Data Grid View Row</returns>
        protected DataGridViewRow CloneRow(DataGridViewRow row)
        {
            DataGridViewRow newRow = row.Clone() as DataGridViewRow;
            newRow.Cells[0].Value = new Bitmap(row.Cells[0].Value as Bitmap);
            newRow.Cells[1].Value = string.Copy(row.Cells[1].Value as string);

            return newRow;
        }
开发者ID:mirror,项目名称:env-man,代码行数:13,代码来源:DgvModifyValueCommand.cs

示例5: AddDuplicateRow

 private int AddDuplicateRow(DataGridViewRow rowTemplate, bool newRow)
 {
     DataGridViewRow dataGridViewRow = (DataGridViewRow) rowTemplate.Clone();
     dataGridViewRow.StateInternal = DataGridViewElementStates.None;
     dataGridViewRow.DataGridViewInternal = this.dataGridView;
     DataGridViewCellCollection cells = dataGridViewRow.Cells;
     int num = 0;
     foreach (DataGridViewCell cell in cells)
     {
         if (newRow)
         {
             cell.Value = cell.DefaultNewRowValue;
         }
         cell.DataGridViewInternal = this.dataGridView;
         cell.OwningColumnInternal = this.DataGridView.Columns[num];
         num++;
     }
     DataGridViewElementStates rowState = rowTemplate.State & ~(DataGridViewElementStates.Selected | DataGridViewElementStates.Displayed);
     if (dataGridViewRow.HasHeaderCell)
     {
         dataGridViewRow.HeaderCell.DataGridViewInternal = this.dataGridView;
         dataGridViewRow.HeaderCell.OwningRowInternal = dataGridViewRow;
     }
     this.DataGridView.OnAddingRow(dataGridViewRow, rowState, true);
     this.rowStates.Add(rowState);
     return this.SharedList.Add(dataGridViewRow);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:27,代码来源:DataGridViewRowCollection.cs

示例6: InsertDuplicateRow

 private void InsertDuplicateRow(int indexDestination, DataGridViewRow rowTemplate, bool firstInsertion, ref Point newCurrentCell)
 {
     DataGridViewRow dataGridViewRow = (DataGridViewRow) rowTemplate.Clone();
     dataGridViewRow.StateInternal = DataGridViewElementStates.None;
     dataGridViewRow.DataGridViewInternal = this.dataGridView;
     DataGridViewCellCollection cells = dataGridViewRow.Cells;
     int num = 0;
     foreach (DataGridViewCell cell in cells)
     {
         cell.DataGridViewInternal = this.dataGridView;
         cell.OwningColumnInternal = this.DataGridView.Columns[num];
         num++;
     }
     DataGridViewElementStates rowState = rowTemplate.State & ~(DataGridViewElementStates.Selected | DataGridViewElementStates.Displayed);
     if (dataGridViewRow.HasHeaderCell)
     {
         dataGridViewRow.HeaderCell.DataGridViewInternal = this.dataGridView;
         dataGridViewRow.HeaderCell.OwningRowInternal = dataGridViewRow;
     }
     this.DataGridView.OnInsertingRow(indexDestination, dataGridViewRow, rowState, ref newCurrentCell, firstInsertion, 1, false);
     this.SharedList.Insert(indexDestination, dataGridViewRow);
     this.rowStates.Insert(indexDestination, rowState);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:23,代码来源:DataGridViewRowCollection.cs

示例7: SetProductDetail

        private void SetProductDetail(DataGridViewRow gRow, double productID)
        {
            bool isDuplicate = false;
            double quantity = 0;
            if (gRow.Cells[indexQTY].Value == null) gRow.Cells[indexQTY].Value = 1;
            if (gRow.Cells[indexQTY].Value.ToString().Trim() == "") gRow.Cells[indexQTY].Value = 1;
            quantity = Convert.ToDouble(gRow.Cells[indexQTY].Value);

            foreach (DataGridViewRow cRow in this.grvSupport.Rows)
            {
                if (!cRow.IsNewRow)
                {
                    if (cRow.Index != gRow.Index && cRow.Cells[indexPRODUCT].Value.ToString() == productID.ToString())
                    {
                        cRow.Cells[indexQTY].Value = (Convert.ToDouble(cRow.Cells[indexQTY].Value) + quantity).ToString(Constz.IntFormat);
                        isDuplicate = true;
                        break;
                    }
                }
            }

            if (isDuplicate)
            {
                if (gRow.IsNewRow)
                {
                    for (int i = 0; i < this.grvSupport.Columns.Count; ++i)
                    {
                        gRow.Cells[i].Value = DBNull.Value;
                    }
                }
                else
                {
                    this.grvSupport.EndEdit();
                    this.grvSupport.Rows.Remove(gRow);
                }

            }
            else
            {
                ProductSaleData data = SaleObj.GetProductPromotion(productID, Appz.CurrentUserData.Warehouse);
                gRow.Cells[indexPRODUCT].Value = data.PRODUCT;
                gRow.Cells[indexUNIT].Value = data.UNIT.ToString();
                gRow.Cells[indexBARCODE].Value = data.BARCODE;
                gRow.Cells[indexNAME].Value = data.PRODUCTNAME;
                gRow.Cells[indexUNITNAME].Value = data.UNITNAME;
                gRow.Cells[indexPRICE].Value = SaleObj.CalculateUnitPrice(data.UNITPRICE, Convert.ToDouble(this.txtVat.Text == "" ? "0" : this.txtVat.Text), data.ISVAT);
                gRow.Cells[indexNORMALDISCOUNT].Value = data.DISCOUNT.ToString();
                gRow.Cells[indexNETPRICE].Value = SaleObj.CalcucateProductTotalItem(Convert.ToDouble(gRow.Cells[indexPRICE].Value), Convert.ToDouble(gRow.Cells[indexQTY].Value), data.DISCOUNT);
                gRow.Cells[indexISVAT].Value = (data.ISVAT == Constz.VAT.Included.Code);

                if (gRow.IsNewRow)
                {
                    SetDataGridViewImageColumnCellStyle();

                    DataGridViewRow newRow = (DataGridViewRow)gRow.Clone();
                    newRow.Cells[indexORDERNO].Value = this.grvSupport.Rows.Count.ToString();
                    newRow.Cells[indexBARCODE].Value = gRow.Cells[indexBARCODE].Value;
                    newRow.Cells[indexNORMALDISCOUNT].Value = gRow.Cells[indexNORMALDISCOUNT].Value;
                    newRow.Cells[indexISVAT].Value = gRow.Cells[indexISVAT].Value;
                    newRow.Cells[indexNAME].Value = gRow.Cells[indexNAME].Value;
                    newRow.Cells[indexNETPRICE].Value = gRow.Cells[indexNETPRICE].Value;
                    newRow.Cells[indexPRICE].Value = gRow.Cells[indexPRICE].Value;
                    newRow.Cells[indexPRODUCT].Value = gRow.Cells[indexPRODUCT].Value;
                    newRow.Cells[indexQTY].Value = gRow.Cells[indexQTY].Value;
                    newRow.Cells[indexUNIT].Value = gRow.Cells[indexUNIT].Value;
                    newRow.Cells[indexUNITNAME].Value = gRow.Cells[indexUNITNAME].Value;

                    for (int i = 0; i < this.grvSupport.Columns.Count; ++i)
                    {
                        gRow.Cells[i].Value = DBNull.Value;
                    }

                    if (!Validate(newRow)) return;

                    this.grvSupport.Rows.Add(newRow);//

                }
            }

            CalculateGrandTotal();
        }
开发者ID:SoftSuite,项目名称:ABB,代码行数:81,代码来源:SupportEdit.cs

示例8: CloneRow

 private static DataGridViewRow CloneRow(DataGridViewRow row)
 {
     var clone = (DataGridViewRow)row.Clone();
     for (int i = 0; i < row.Cells.Count; i++)
     {
         clone.Cells[i].Value = row.Cells[i].Value;
     }
     return clone;
 }
开发者ID:kanbang,项目名称:Colt,代码行数:9,代码来源:LayerPropertiesSectionCtrl.cs

示例9: SetProductDetail

        private void SetProductDetail(DataGridViewRow gRow, double productID)
        {
            bool isDuplicate = false;
            double quantity = 0;
            if (gRow.Cells[indexQTY].Value == null) gRow.Cells[indexQTY].Value = 1;
            if (gRow.Cells[indexQTY].Value.ToString().Trim() == "") gRow.Cells[indexQTY].Value = 1;
            quantity = Convert.ToDouble(gRow.Cells[indexQTY].Value);

            foreach (DataGridViewRow cRow in this.grvStockin.Rows)
            {
                if (!cRow.IsNewRow)
                {
                    if (cRow.Index != gRow.Index && cRow.Cells[indexPRODUCT].Value.ToString() == productID.ToString())
                    {
                        cRow.Cells[indexQTY].Value = (Convert.ToDouble(cRow.Cells[indexQTY].Value) + quantity).ToString(Constz.IntFormat);
                        isDuplicate = true;
                        break;
                    }
                }
            }

            if (isDuplicate)
            {
                if (gRow.IsNewRow)
                {
                    for (int i = 0; i < this.grvStockin.Columns.Count; ++i)
                    {
                        gRow.Cells[i].Value = DBNull.Value;
                    }
                }
                else
                {
                    this.grvStockin.EndEdit();
                    this.grvStockin.Rows.Remove(gRow);
                }

            }
            else
            {
                ProductSaleData data = SaleObj.GetProductPromotion(productID, 3);
                gRow.Cells[indexPRODUCT].Value = data.PRODUCT;
                gRow.Cells[indexUNIT].Value = data.UNIT.ToString();
                gRow.Cells[indexBARCODE].Value = data.BARCODE;
                gRow.Cells[indexNAME].Value = data.PRODUCTNAME;
                gRow.Cells[indexUNITNAME].Value = data.UNITNAME;
                gRow.Cells[indexPRICE].Value = data.UNITPRICE;
                gRow.Cells[indexNETPRICE].Value = data.UNITPRICE * Convert.ToDouble(gRow.Cells[indexQTY].Value);

                if (gRow.IsNewRow)
                {
                    SetDataGridViewImageColumnCellStyle();

                    DataGridViewRow newRow = (DataGridViewRow)gRow.Clone();
                    newRow.Cells[indexORDERNO].Value = this.grvStockin.Rows.Count.ToString();
                    newRow.Cells[indexBARCODE].Value = gRow.Cells[indexBARCODE].Value;
                    newRow.Cells[indexNAME].Value = gRow.Cells[indexNAME].Value;
                    newRow.Cells[indexNETPRICE].Value = gRow.Cells[indexNETPRICE].Value;
                    newRow.Cells[indexPRICE].Value = gRow.Cells[indexPRICE].Value;
                    newRow.Cells[indexPRODUCT].Value = gRow.Cells[indexPRODUCT].Value;
                    newRow.Cells[indexQTY].Value = gRow.Cells[indexQTY].Value;
                    newRow.Cells[indexUNIT].Value = gRow.Cells[indexUNIT].Value;
                    newRow.Cells[indexUNITNAME].Value = gRow.Cells[indexUNITNAME].Value;

                    for (int i = 0; i < this.grvStockin.Columns.Count; ++i)
                    {
                        gRow.Cells[i].Value = DBNull.Value;
                    }

                    if (!Validate(newRow)) return;

                    this.grvStockin.Rows.Add(newRow);//

                }
            }

            Calculate();
        }
开发者ID:SoftSuite,项目名称:ABB,代码行数:77,代码来源:StockInEdit.cs

示例10: AddDuplicateRow

        private int AddDuplicateRow(DataGridViewRow rowTemplate, bool newRow)
        {
            Debug.Assert(this.DataGridView != null);

            DataGridViewRow dataGridViewRow = (DataGridViewRow) rowTemplate.Clone();
            dataGridViewRow.StateInternal = DataGridViewElementStates.None;
            dataGridViewRow.DataGridViewInternal = this.dataGridView;
            DataGridViewCellCollection dgvcc = dataGridViewRow.Cells;
            int columnIndex = 0;
            foreach (DataGridViewCell dataGridViewCell in dgvcc)
            {
                if (newRow)
                {
                    dataGridViewCell.Value = dataGridViewCell.DefaultNewRowValue;
                }
                dataGridViewCell.DataGridViewInternal = this.dataGridView;
                dataGridViewCell.OwningColumnInternal = this.DataGridView.Columns[columnIndex];
                columnIndex++;
            }
            DataGridViewElementStates rowState = rowTemplate.State & ~(DataGridViewElementStates.Selected | DataGridViewElementStates.Displayed);
            if (dataGridViewRow.HasHeaderCell)
            {
                dataGridViewRow.HeaderCell.DataGridViewInternal = this.dataGridView;
                dataGridViewRow.HeaderCell.OwningRowInternal = dataGridViewRow;
            }

            this.DataGridView.OnAddingRow(dataGridViewRow, rowState, true /*checkFrozenState*/);   // will throw an exception if the addition is illegal

#if DEBUG
            this.DataGridView.dataStoreAccessAllowed = false;
            this.cachedRowHeightsAccessAllowed = false;
            this.cachedRowCountsAccessAllowed = false;
#endif
            Debug.Assert(dataGridViewRow.Index == -1);
            this.rowStates.Add(rowState);
            return this.SharedList.Add(dataGridViewRow);
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:37,代码来源:DataGridViewRowCollection.cs

示例11: InsertDuplicateRow

        private void InsertDuplicateRow(int indexDestination, DataGridViewRow rowTemplate, bool firstInsertion, ref Point newCurrentCell)
        {
            Debug.Assert(this.DataGridView != null);

            DataGridViewRow dataGridViewRow = (DataGridViewRow) rowTemplate.Clone();
            dataGridViewRow.StateInternal = DataGridViewElementStates.None;
            dataGridViewRow.DataGridViewInternal = this.dataGridView;
            DataGridViewCellCollection dgvcc = dataGridViewRow.Cells;
            int columnIndex = 0;
            foreach (DataGridViewCell dataGridViewCell in dgvcc)
            {
                dataGridViewCell.DataGridViewInternal = this.dataGridView;
                dataGridViewCell.OwningColumnInternal = this.DataGridView.Columns[columnIndex];
                columnIndex++;
            }
            DataGridViewElementStates rowState = rowTemplate.State & ~(DataGridViewElementStates.Selected | DataGridViewElementStates.Displayed);
            if (dataGridViewRow.HasHeaderCell)
            {
                dataGridViewRow.HeaderCell.DataGridViewInternal = this.dataGridView;
                dataGridViewRow.HeaderCell.OwningRowInternal = dataGridViewRow;
            }

            this.DataGridView.OnInsertingRow(indexDestination, dataGridViewRow, rowState, ref newCurrentCell, firstInsertion, 1, false /*force*/);   // will throw an exception if the insertion is illegal

            Debug.Assert(dataGridViewRow.Index == -1);
            this.SharedList.Insert(indexDestination, dataGridViewRow);
            this.rowStates.Insert(indexDestination, rowState);
            Debug.Assert(this.rowStates.Count == this.SharedList.Count);
#if DEBUG
            this.DataGridView.dataStoreAccessAllowed = false;
            this.cachedRowHeightsAccessAllowed = false;
            this.cachedRowCountsAccessAllowed = false;
#endif
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:34,代码来源:DataGridViewRowCollection.cs


注:本文中的System.Windows.Forms.DataGridViewRow.Clone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。