private void gridView_CellParsing(object sender, DataGridViewCellParsingEventArgs e)
            {
                string value = e.Value.ToString();

                if (string.IsNullOrWhiteSpace(value))
                {
                    return;
                }
                value = value.Trim();

                switch (e.ColumnIndex)
                {
                case COLUMN_SEQUENCE:
                {
                    var seqCharge = new SequenceAndCharge(value);
                    e.Value = seqCharge.ModifiedSequence;
                    Items[e.RowIndex].Adduct = seqCharge.Charge;
                    e.ParsingApplied         = true;
                }
                break;

                case COLUMN_PRODUCT_ION:
                {
                    var fragCharge = new FragmentAndCharge(value);
                    e.Value = fragCharge.FragmentIon;
                    Items[e.RowIndex].ProductAdduct = fragCharge.Adduct;
                    e.ParsingApplied = true;
                }
                break;
                }
            }
            protected override bool DoCellValidating(int rowIndex, int columnIndex, string value)
            {
                string errorText = null;

                if (columnIndex == COLUMN_SEQUENCE && GridView.IsCurrentCellInEditMode)
                {
                    string sequence = value;
                    errorText = ValidateSequence(sequence);
                }
                else if (columnIndex == COLUMN_PRODUCT_ION && GridView.IsCurrentCellInEditMode)
                {
                    string chargeText = value;
                    errorText = ValidateProductIon(chargeText);
                }
                else if (columnIndex == COLUMN_VALUE && GridView.IsCurrentCellInEditMode)
                {
                    string optimizedText = value;
                    errorText = ValidateOptimizedValue(optimizedText);
                }
                if (errorText == null && GridView.IsCurrentCellInEditMode &&
                    (columnIndex == COLUMN_SEQUENCE || columnIndex == COLUMN_PRODUCT_ION))
                {
                    var             curRow = GridView.Rows[rowIndex].DataBoundItem as DbOptimization;
                    OptimizationKey curKey = curRow != null ? new OptimizationKey(curRow.Key) : new OptimizationKey();
                    switch (columnIndex)
                    {
                    case COLUMN_SEQUENCE:
                    {
                        var seqCharge = new SequenceAndCharge(value);
                        curKey.PeptideModSeq   = seqCharge.ModifiedSequence;
                        curKey.PrecursorAdduct = seqCharge.Charge;
                        break;
                    }

                    case COLUMN_PRODUCT_ION:
                    {
                        var fragCharge = new FragmentAndCharge(value);
                        curKey.FragmentIon   = fragCharge.FragmentIon;
                        curKey.ProductAdduct = fragCharge.Adduct;
                        break;
                    }
                    }
                    int iExist = Optimizations.ToArray().IndexOf(item => Equals(item.Key, curKey));
                    if (iExist != -1 && iExist != rowIndex)
                    {
                        errorText = string.Format(
                            Resources.LibraryGridViewDriver_DoCellValidating_There_is_already_an_optimization_with_sequence___0___and_product_ion___2___in_the_list_,
                            curKey.PeptideModSeq, Transition.GetChargeIndicator(curKey.PrecursorAdduct), curKey.FragmentIon, Transition.GetChargeIndicator(curKey.ProductAdduct));
                    }
                }
                if (errorText != null)
                {
                    MessageDlg.Show(MessageParent, errorText);
                    return(false);
                }

                return(true);
            }
            protected override void DoPaste()
            {
                var  libraryOptimizationsNew = new List <DbOptimization>();
                bool add = false;

                if (Equals(ViewType, ExportOptimize.CE))
                {
                    add = GridView.DoPaste(MessageParent, ValidateOptimizationRow,
                                           values =>
                    {
                        var seqCharge  = new SequenceAndCharge(values[0]);
                        var fragCharge = new FragmentAndCharge(values[1]);
                        libraryOptimizationsNew.Add(new DbOptimization(ViewDbType,
                                                                       seqCharge.ModifiedSequence,
                                                                       seqCharge.Charge,
                                                                       fragCharge.FragmentIon,
                                                                       fragCharge.Adduct,
                                                                       double.Parse(values[2])));
                    });
                }
                else if (Equals(ViewType, ExportOptimize.COV))
                {
                    add = GridView.DoPaste(MessageParent, ValidateOptimizationRow,
                                           values =>
                    {
                        var seqCharge = new SequenceAndCharge(values[0]);
                        libraryOptimizationsNew.Add(new DbOptimization(ViewDbType,
                                                                       seqCharge.ModifiedSequence,
                                                                       seqCharge.Charge,
                                                                       null, Adduct.EMPTY, double.Parse(values[1])));
                    });
                }

                if (add)
                {
                    AddToLibrary(libraryOptimizationsNew);
                }
            }