Hi,
I am trying to paste multi-cell multi-row data (from Excel) into xamGrid when cursor is in the active cell which is in edit mode. So, it is pasting only the first row of data into this cell. I need to make it behaving like doing normal pasting - cell to cell row to row, not into single cell.
Any suggestions.
Thank you.
Check these blog posts:http://community.infragistics.com/blogs/nikolay_zhekov/archive/2010/10/19/clipboard-extensions-for-xamgrid.aspxhttp://blogs.infragistics.com/blogs/kiril_matev/archive/2010/10/19/quick-and-effective-clipboard-support-in-the-xamgrid-10-3-using-clipboard-extensions.aspxHTH
Unfortunately, it does not apply. This pasting event will fire when focus is not on cell in edit mode. Please read my question - I need to paste cells/rows when cursor is on cell which is in edit mode.
Also, I cannot intercept CTRL+V - there many posts here showing that this does not work.
Thanks
Well, the code in the blog posts is just a starting point to help you with the pasting. You'll need to write a little bit of code to intercept ctrl-v, because it's usually handled by the editor. When you handle Ctrl-V you can invoke the PasteFromClipboard method to use the clipboard parsing capabilies of the XamGrid.public TestView(){ this.InitializeComponent();
this.XGrid.ClipboardPasting += new EventHandler<ClipboardPastingEventArgs>(XGrid_ClipboardPasting); this.XGrid.Loaded += new RoutedEventHandler(XGrid_Loaded); this.XGrid.Unloaded += new RoutedEventHandler(XGrid_Unloaded);}
void XGrid_Unloaded(object sender, RoutedEventArgs e){ this.XGrid.RemoveHandler(UIElement.KeyUpEvent, new KeyEventHandler(XGrid_KeyUp));}
void XGrid_Loaded(object sender, RoutedEventArgs e){ this.XGrid.AddHandler(UIElement.KeyUpEvent, new KeyEventHandler(XGrid_KeyUp), true);}
void XGrid_KeyUp(object sender, KeyEventArgs e){ if (e.Key == Key.V && Keyboard.Modifiers == ModifierKeys.Control) { this.XGrid.PasteFromClipboard(); }}
private void XGrid_ClipboardPasting(object sender, ClipboardPastingEventArgs e){ // use the helpers from the blogpost}
HTH
Thank you Nikolay,
this definitely helped.
Victor