I have a radgridview that I've enabled pasting. Everything works great but for some reason when I right click and hit paste no matter how many rows I'm coping the pasting event fires twice thus duplicating the input rows.
private void RgvSup_Pasting(object sender, Telerik.WinControls.UI.GridViewClipboardEventArgs e){
Cursor.Current = Cursors.WaitCursor;
try
{
// paste row data
if (RgvSup.CurrentRow is GridViewNewRowInfo)
{
if (Clipboard.GetText() != string.Empty && Clipboard.GetText() != "")
{
string[] lines = Clipboard.GetText().Split(new string[] { "\r\n" }, StringSplitOptions.None);
try
{
foreach (string rowInfo in lines)
{
string[] cellVal = rowInfo.Split('\t');
if (cellVal.Length >= 9)
{
SUPPLIER ObjSup = new SUPPLIER();
try { ObjSup.SUP_NAME = cellVal[0]; } catch { }
if (cellVal[1].Contains(";"))
cellVal[1] = cellVal[1].Split(';').GetValue(0).ToString();
try { ObjSup.SUP_PUL_CAT_ID = decimal.Parse(cellVal[1]); } catch { ObjSup.SUP_PUL_CAT_ID = null; }
try { ObjSup.SUP_PHONE = ClsCommon.SetPhone(cellVal[2]); } catch { }
try { ObjSup.SUP_PCONT_NAME = cellVal[3]; } catch { }
try { ObjSup.SUP_PCONT_CCELL = ClsCommon.SetPhone(cellVal[4]); } catch { }
try { ObjSup.SUP_ADDRESS = cellVal[5]; } catch { }
try { ObjSup.SUP_CITY = cellVal[6]; } catch { }
if (cellVal[7].Contains(";"))
cellVal[7] = cellVal[7].Split(';').GetValue(0).ToString();
try { ObjSup.SUP_ST_ID = decimal.Parse(cellVal[7]); } catch { ObjSup.SUP_ST_ID = null; }
try { ObjSup.SUP_ZIP = ClsCommon.SetZip(cellVal[8]); } catch { }
ObjSup.SUP_CL_ACTIVE_ID = 1;
MstEnt.eSUPPLIER.Add(ObjSup);
}
}
}
catch
{
MessageBox.Show("Incompatible DataSources");
}
ClsCommon.SaveMstEnt(MstEnt, "RpurfEditSup.cs", "RgvSup_Pasting");
RefreshData();
MessageBox.Show("Completed");
}
}
}
catch (Exception Ex)
{
ClsCommon.WriteAppError(Ex, "RpurfEditSup.cs", "RgvSup_Pasting");
}
Cursor.Current = Cursors.Default;
}