We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Adding rows by Copy n'Paste from Excel

Thread ID:

Created:

Updated:

Platform:

Replies:

3092 Mar 1,2003 03:20 PM Mar 4,2003 12:29 PM Windows Forms 2
loading
Tags: GridControl
Thomas Domurat
Asked On March 1, 2003 03:20 PM

Would like to add rows to a data-bound grid by pasting rows from Excel. The underlying table has an identity primary key, which I would NOT copy a value into this field. Copy and paste works fine if the source and destination ranges are the same. When I try add a range of values, I get: "An unhandled exception of type 'System.IndexOutOfRangeException' occured in system.data.dll Additioanl information: Index 1 is not non-negative and below total rows count." Is there sample of code of how this can be done? I would like the ability to create multiple rows at one time by copying from Excel.

Administrator [Syncfusion]
Replied On March 3, 2003 02:46 PM

Hi Tom, you need to handle the GridModel.ClipboardPaste event. You can subscribe to it via dataBoundGrid.Model.ClipboardPaste. I am attaching some source code from the grid library that might be of use. What you will need to do is check if you need to add rows, and then call AddNew, add the data for the row and then EndEdit for every new row that needs to be added to the datasource. You could also just add the data directly to the datasource and then just refresh the grid. In this case calling SuspendBinding/ResumeBinding and/or BeginUpdate/EndUpdate might be of use. In a future version I would like to have this an option so that the grid automatically detects when it needs to add rows and act accordingly but for now you have to code this yourself. Let me know if you run into trouble. Stefan

Thomas Domurat
Replied On March 4, 2003 12:29 PM

Would there be a VB code example? I would greatly appreciate it if you could post that if one exists. Thanks.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;