How to use default context menu items like copy from radgrid context menu as i am able to use delete item from a gird , delete a row by right clicking on the context menu items and able to delete a row, similarly i need copy a row using context menu copy
Thanks,
Senthil
8 Answers, 1 is accepted
The copy context menu item can copy/paste cell values between grid cells. Currently, the functionality for copy/paste of grid rows between different instances of RadGridView is not built-in. Nevertheless, you can find sample implementations in following KB articles:
Copy/Pasting rows in and between RadGridViews
Implementing "Copy/Paste to Excel" functionality in RadGridView for WinForms
We plan to include this functionality in RadGridView in one of our upcoming releases.
When there is an active editor in RadGridView, you can use all standard hot keys in order to copy/paste text (e.g. Control+C; Control+V).
I hope this helps.
Jack
the Telerik team
Hi Team,
I have a problem trying to paste a value into the cells selected in the radgrid (Winforms).
The thing is that I want to copy an specific value from a cell and then copy that value into the cells that I have selected.
How can I achieve that?
Thanks a lot in advance!
You can select a certain cell, right click with the mouse and select the Copy option from the context menu. This will copy only the specific cell's value. Then select another cell, right click with the mouse and select the Paste option from the context menu. The value will be pasted in the target cell. The attached gif file illustrates the behavior on my end with the latest version.
I hope this information helps.
Regards,
Dess
Progress Telerik
Hi Dess,
Yes, I know I can do that but I was refering to another thing.
We need to copy one value (for example "20"), which we do it as you mentioned above or even using Ctrl+C but we want to paste that value into the cells selected (for differents rows), instead of having to do it one by one. Sometimes we need to fill one cell for 100 rows with that value so it will be easy if you copy the value first and then paste it in all the selected cells where we want to paste it like we do it in Excel. My question is regarding "pasting into multiple cells selected". How can we achieve that? How can we paste one value into various selected cells?
It is very urgent for us to achieve this. I know that for WPF it is SelectionMode="Extended" and SelectionUnit="AllCellSelected" but how can we achieve that using winforms?
Please help us!!! Many thanks in advance!
If I understand your requirement correctly, you want to copy a single cell's value, select many cells and paste the copied value to all of the selected cells. I suppose that you set the SelectionMode property to CellSelect. Then, you can handle the RadGridView.Pasting event and set the clipboard value to all selected cells. Here is a sample code snippet which result is illustrated in the attached gif file:
public
RadForm1()
{
InitializeComponent();
this
.radGridView1.SelectionMode = Telerik.WinControls.UI.GridViewSelectionMode.CellSelect;
this
.radGridView1.MultiSelect =
true
;
this
.radGridView1.Pasting += radGridView1_Pasting;
}
private
void
radGridView1_Pasting(
object
sender, Telerik.WinControls.UI.GridViewClipboardEventArgs e)
{
string
data = Clipboard.GetData(DataFormats.Text).ToString();
if
(data !=
string
.Empty)
{
this
.radGridView1.BeginUpdate();
foreach
(GridViewCellInfo cell
in
this
.radGridView1.SelectedCells)
{
if
(cell.IsCurrent ==
false
)
{
cell.Value = data;
}
}
this
.radGridView1.EndUpdate();
}
}
Off topic, note that most of the forum threads are reviewed by Telerik representatives and we address the questions asked by our customers in the forums as well. Moreover, threads are handled according to license and time of posting, so if it is an urgent problem, we suggest you use a support ticket, which would be handled before a forum thread.
I hope this information helps.
Regards,
Dess
Progress Telerik
Hi Dess, I try to apply this function to RadSpreadSheet with merged cells, when left click show the opcion to copy/paste/delete.. etc,
so when copy the cells and paste appears a pop up that say "Cannot change part of a merged cell." Do you know a way to can copy paste?
RadGridView and RadSpreadsheet are two different controls and they have different internal implementation. That is why the suggested approach for pasting in RadGridView is not applicable for RadSpreadsheet.
You can prevent the default logic for pasting in order to prevent the message box from appearing. For this purpose it is necessary to cancel the SpreadsheetElement.WorkbookCommandExecuting event, store information which cells are merged, then unmerge the cells, set the stored value in the clipboard and then merge the cells again.
private
void
SpreadsheetElement_WorkbookCommandExecuting(
object
sender, Telerik.Windows.Documents.Spreadsheet.Commands.CommandExecutingEventArgs e)
{
if
(e.CommandName ==
"SetCellPropertyValuesCommand"
)
{
e.Cancel();
//TODO
}
}
Additional information about mergin cells and setting values to the cells is available in the following help articles:
https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/features/merge-unmerge-cells
https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/working-with-cells/cell-value-types
I hope this information helps. If you need any further assistance please don't hesitate to contact me.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik