This is a migrated thread and some comments may be shown as answers.

Default Context Menu

5 Answers 95 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Joe Sugden
Top achievements
Rank 1
Joe Sugden asked on 13 Dec 2010, 11:02 PM
This might be a stupid question but I've been trying to figure this out for hours now.

How do I enable the default Context Menu with Copy, Paste, etc. like the ones on the demos without explicitly adding those options in code behind to the menu???
My AllowCellContextMenu is set to true, but nothing shows on right click.
I also have another form that somebody else here programmed and in the ContextMenuOpening event one grid has a Copy option already there and another grid has nothing, both have AllowCellContextMenu set to true and none of them have any code for adding items to context menu...

Please help,

Thanks

5 Answers, 1 is accepted

Sort by
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 14 Dec 2010, 12:58 AM
Hi Joe,

You should, as you said get the context menu. Are you handling the contextmenuopening event and clearing out the menu before adding to it by chance?

Try this very simple scenario. Just a RadGridView on a form. You should get the result as per the screenshot
Richard

Imports Telerik.WinControls
Imports Telerik.WinControls.UI
  
  
Public Class Form1
  
    Private Sub Form1_Load(ByVal sender As System.Object,
                           ByVal e As System.EventArgs) Handles MyBase.Load
  
  
  
        Me.RadGridView1.MultiSelect = True
        Me.RadGridView1.AllowRowResize = False
        Me.RadGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill
  
        Me.RadGridView1.Columns.Add(New GridViewTextBoxColumn("A"))
        Me.RadGridView1.Columns.Add(New GridViewDecimalColumn("B"))
        Dim rowInfo As GridViewRowInfo = Me.RadGridView1.Rows.AddNew()
        rowInfo.Cells(0).Value = "A1"
        rowInfo.Cells(1).Value = 2.99
        rowInfo = Me.RadGridView1.Rows.AddNew()
        rowInfo.Cells(0).Value = "A2"
        rowInfo.Cells(1).Value = 3.99
        rowInfo = Me.RadGridView1.Rows.AddNew()
        rowInfo.Cells(0).Value = "A3"
        rowInfo.Cells(1).Value = 3.99
        rowInfo = Me.RadGridView1.Rows.AddNew()
        rowInfo.Cells(0).Value = "A4"
        rowInfo.Cells(1).Value = 3.99
  
  
    End Sub
  
End Class

0
Kurt
Top achievements
Rank 1
answered on 03 Nov 2013, 08:25 PM
Hi All,

I had this same problem with two grids I setup in the same project, one had copy the other didn't.

I tracked it down to ReadOnly being set in the one that didn't work. Once I changed ReadOnly to false the context menu suddenly worked and had Copy in it, and I could copy the contents. Strange because I would have thought Copy is a read function so wouldn't be disabled, but is obviously disabled along with Cut and Paste.

Regards,

Kurt
0
Stefan
Telerik team
answered on 05 Nov 2013, 10:44 AM
Hi Kurt,

I have added the a feature request for having the copy option even when the grid is in ReadOnly mode to PITS. You can add your vote and track its status here: http://www.telerik.com/support/pits.aspx#/details/Issue=16097

Until the feature request is implemented, you can add your own menu option in the ContextMenuOpening event: http://www.telerik.com/help/winforms/gridview-context-menus-modifying-the-default-context-menu.html.

I hope this helps.

Regards,
Stefan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Kurt
Top achievements
Rank 1
answered on 07 Nov 2013, 10:34 PM
Hi Stefan,

One thing I noticed with the copy function is when I bind the grid to a DataTable with DateTime columns;
    
Readings.Columns.Add("Index", typeof(Int32));
Readings.Columns.Add("Date", typeof(DateTime));
Readings.Columns.Add("Time", typeof(DateTime));
Readings.Columns.Add("Elapsed", typeof(TimeSpan));
Readings.Columns.Add("ReadingsHum", typeof(Double));
Readings.Columns.Add("ReadingsTemp", typeof(Double));
Readings.Columns.Add("Event", typeof(String));
Readings.Columns.Add("Annotation", typeof(String));

When I use the copy function the output is like this;

1 2006-01-10 13:33 p.m. 2006-01-10 13:33 p.m. 00:00:00 26.1
2 2006-01-10 13:38 p.m. 2006-01-10 13:38 p.m. 00:05:00 26.3 EVENT_DOWNLOAD
3 2006-01-10 13:43 p.m. 2006-01-10 13:43 p.m. 00:10:00 26.6
4 2006-01-10 13:48 p.m. 2006-01-10 13:48 p.m. 00:15:00 26.7
5 2006-01-10 13:53 p.m. 2006-01-10 13:53 p.m. 00:20:00 26.8

127 2006-01-11 00:03 a.m. 2006-01-11 00:03 a.m. 10:30:00 22.8
128 2006-01-11 00:08 a.m. 2006-01-11 00:08 a.m. 10:35:00 22.8
129 2006-01-11 00:13 a.m. 2006-01-11 00:13 a.m. 10:40:00 22.7

146 2006-01-11 01:38 a.m. 2006-01-11 01:38 a.m. 12:05:00 22.3
147 2006-01-11 01:43 a.m. 2006-01-11 01:43 a.m. 12:10:00 22.3
148 2006-01-11 01:48 a.m. 2006-01-11 01:48 a.m. 12:15:00 22.3
149 2006-01-11 01:53 a.m. 2006-01-11 01:53 a.m. 12:20:00 22.2

As you can see it is treating the times as 24HR time but also including a.m. or p.m. which tends to confuse excel when pasting the copied data. I just wondered at the reasoning behind this, and if there is any way to alter it via some setting or column definition?

Best Regards,

Kurt


0
Stefan
Telerik team
answered on 12 Nov 2013, 11:39 AM
Hello Kurt,

Thank you for writing.

I can confirm that the copied datetime format is incorrect. I have logged this case and we will remove the AM/PM suffix as it is not needed. You can add your vote and subscribe for status change alerts here: http://www.telerik.com/support/pits.aspx#/public/winforms/16136.

I have updated your Telerik Points for this report.

For the time being. you can use the Copying event of the grid to manually populate the clipboard if needed.

Off topic, I would like to kindly ask you to open new threads for subjects that are not related to the initial subject of a thread. 

Regards,
Stefan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
Joe Sugden
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Kurt
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or