C
chh.552
Guest
private string ClipboardData
{
get
{
IDataObject iData = Clipboard.GetDataObject();
if (iData == null) return '';
if (iData.GetDataPresent(DataFormats.Text))
return (string)iData.GetData(DataFormats.Text);
return '';
}
set { Clipboard.SetDataObject(value); }
}
private void CopyRowAdd(string data, int idx)
{
try
{
DataTable tblData = (DataTable)grdXYMappingInfo.DataSource;
DataRow newRow = tblData.NewRow();
string[] rawRowData = data.Split(new char[] { '\r', '\x09' });
string[] RowData = new string[tblData.Columns.Count];
for (int i = 0; i < RowData.Length; i++)
{
if (i >= tblData.Columns.Count) break;
else
{
newRow = RowData;
}
}
tblData.Rows.InsertAt(newRow, grvXYMappingInfo.FocusedRowHandle + idx);
}
catch (Exception x)
{
System.Console.WriteLine(x.Message);
}
}
private void grvXYMappingInfo_KeyDown(object sender, KeyEventArgs e)
{
if (e.Control && e.KeyCode == Keys.C)
{
grvXYMappingInfo.CopyToClipboard();
}
else if (e.Control && e.KeyCode == Keys.V)
{
try
{
string[] selectedRow = ClipboardData.Split('\n');
string[] addRow = new string[selectedRow.Length - 1];
System.Array.Copy(selectedRow, 1, addRow, 0, selectedRow.Length - 1);
if (addRow.Length < 1) return;
int rowidx = 1;
foreach (string row in addRow)
{
CopyRowAdd(row, rowidx);
rowidx++;
}
}
catch (Exception x)
{
System.Console.WriteLine(x.Message);
}
}
}
Continue reading...
{
get
{
IDataObject iData = Clipboard.GetDataObject();
if (iData == null) return '';
if (iData.GetDataPresent(DataFormats.Text))
return (string)iData.GetData(DataFormats.Text);
return '';
}
set { Clipboard.SetDataObject(value); }
}
private void CopyRowAdd(string data, int idx)
{
try
{
DataTable tblData = (DataTable)grdXYMappingInfo.DataSource;
DataRow newRow = tblData.NewRow();
string[] rawRowData = data.Split(new char[] { '\r', '\x09' });
string[] RowData = new string[tblData.Columns.Count];
for (int i = 0; i < RowData.Length; i++)
{
if (i >= tblData.Columns.Count) break;
else
{
newRow = RowData;
}
}
tblData.Rows.InsertAt(newRow, grvXYMappingInfo.FocusedRowHandle + idx);
}
catch (Exception x)
{
System.Console.WriteLine(x.Message);
}
}
private void grvXYMappingInfo_KeyDown(object sender, KeyEventArgs e)
{
if (e.Control && e.KeyCode == Keys.C)
{
grvXYMappingInfo.CopyToClipboard();
}
else if (e.Control && e.KeyCode == Keys.V)
{
try
{
string[] selectedRow = ClipboardData.Split('\n');
string[] addRow = new string[selectedRow.Length - 1];
System.Array.Copy(selectedRow, 1, addRow, 0, selectedRow.Length - 1);
if (addRow.Length < 1) return;
int rowidx = 1;
foreach (string row in addRow)
{
CopyRowAdd(row, rowidx);
rowidx++;
}
}
catch (Exception x)
{
System.Console.WriteLine(x.Message);
}
}
}
Continue reading...