[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

pasting into a DataGrid

Posted on 2005-04-06
1
Medium Priority
?
167 Views
Last Modified: 2010-04-23
Does anybody have any code or advise on how i can paste into a grid.

Of course i can already paste into one cell at a time but how could i for example:

copy 3 horizontal cells in Excel, lets say cells A1 to C1.

then go to my DataGrid which has rows of data, click into the top left cell, hit Ctrl-V and get the 3 values that i copied from excel and have them paste into the first 3 cells of my Grid.

is this possible at all ???

Any help or advise would be greatly appreciated.

Thank a lot
0
Comment
Question by:allff
1 Comment
 
LVL 19

Accepted Solution

by:
arif_eqbal earned 500 total points
ID: 13724210
There are quite a few ways you can achieve what you want, I will list them in order of preferences...

1.
Since you have a dataGrid you must be having a DataTable which is used to populate the Grid. For a grid all data related operations should be done on that underlying Table, (your DataTable might be local to a function, you can make it a form level variable so that it can be accessed)
So say your DataTable that the Grid bounds to is DT
then

       Dim DR As DataRow
        DR = DT.Rows(2) 'Say its the Second Row you want to manipulate
        DR(0) = A1
        DR(1) = B1
        DR(2) = C1

this will do what you want, A1/B1/C1 are the variables holding the copied values from the Excel Cells

2.
DataGrid.Item(1, 1) = "Any Value"  'Put some value in cell 1,1 of the Grid

3.
Now in case you have used Clipboard to copy data from Excel, you might be forced to Use Ctrl+V, this is not recommended though as this type of programs are not very robust, anyway here goes

        DataGrid.CurrentCell = New DataGridCell(1, 1) 'Set Focus on the Cell
        SendKeys.Send("^(V)")  'Use SendKeys to simulate Paste
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question