4 Answers, 1 is accepted
0
Prad
Top achievements
Rank 2
answered on 26 Jan 2009, 07:49 PM
Hi Pratrick,
Hope this helps. The below code is for copy.
Hope this helps. The below code is for copy.
private void CopyClipBoard(RadGridView rgvResult, KeyEventArgs e) |
{ |
try |
{ |
if (e.KeyCode == Keys.C && e.Control) |
{ |
//change the code below according to your custom logic |
string copyStr = ConvertSelectedDataToString(rgvResult); |
Clipboard.SetDataObject(copyStr); |
} |
if (e.KeyCode == Keys.A && e.Control) |
{ |
rgvResult.GridElement.BeginUpdate(); |
for (int row = 0; row < rgvResult.Rows.Count; row++) |
{ |
rgvResult.Rows[row].IsSelected = true; |
} |
rgvResult.GridElement.EndUpdate(); |
} |
} |
catch (Exception lobjException) |
{ MessageBox.Show(lobjException.ToString(); |
} |
} |
private void radGridView1_KeyDown(object sender, KeyEventArgs e) |
{ |
CopyClipBoard(this.radGridView1, e); |
} |
0
Hello Pradeep,
Thank you for sharing your solution.
Partick, in addition to the Pradeep's solution, you can also refer to the following Knowledge Base article regarding this topic: Copy/Pasting rows in and between RadGridViews (CSV format).
If you have additional questions, feel free to contact me.
Best wishes,
Nikolay
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Thank you for sharing your solution.
Partick, in addition to the Pradeep's solution, you can also refer to the following Knowledge Base article regarding this topic: Copy/Pasting rows in and between RadGridViews (CSV format).
If you have additional questions, feel free to contact me.
Best wishes,
Nikolay
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Geert
Top achievements
Rank 1
answered on 16 Feb 2009, 09:26 AM
Hello,
I'm also looking for a dynamic solution to copy and paste a selection of rows.
In the knowledge base article the code is working for 3 columns
Is there also code which works with 1 colum, and with the same code for X-columns?
Tnx!
I'm also looking for a dynamic solution to copy and paste a selection of rows.
In the knowledge base article the code is working for 3 columns
row[0] = cellVal[0];
row[1] = cellVal[1];
row[2] = cellVal[2];
Is there also code which works with 1 colum, and with the same code for X-columns?
Tnx!
0
Hello Geert,
Thank you for the question.
In the Knowledge Base article the Copy/Paste functionality is demonstrated in a sample scenario of 3 columns. However, if you want to have a code snippet working in scenarios of different number of columns, please refer to the following code block below:
As you can see, the row[j] setting depends on the number of the columns in the destination RadGridView. So, if you have a RadGridView with 6 columns, the above code will be equal to:
I hope this helps. If you have additional questions, feel free to contact me.
Best wishes,
Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Thank you for the question.
In the Knowledge Base article the Copy/Paste functionality is demonstrated in a sample scenario of 3 columns. However, if you want to have a code snippet working in scenarios of different number of columns, please refer to the following code block below:
for (int j = 0; j < radGridView.Columns.Count; j++) |
{ |
row[j] = cellVal[j]; |
} |
As you can see, the row[j] setting depends on the number of the columns in the destination RadGridView. So, if you have a RadGridView with 6 columns, the above code will be equal to:
row[0] = cellVal[0]; |
row[1] = cellVal[1]; |
row[2] = cellVal[2]; |
row[3] = cellVal[3]; |
row[4] = cellVal[4]; |
row[5] = cellVal[5]; |
I hope this helps. If you have additional questions, feel free to contact me.
Best wishes,
Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.