Click here to Skip to main content
15,894,410 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am stuck with the columns as of right now.

here is my code:

Dim s As New StringBuilder
      Dim str As String


      For Each dr As DataRow In dt.Rows
          For i As Integer = 0 To dt.Columns.Count - 1
              For Each col As DataColumn In dt.Columns

                  str = dr.Item(col.ColumnName).ToString() + "|"

                  s.Append(str)

              Next
          Next
      Next



Instead of each column being individualized, all the column names want to run together into 1 column. for instance I have an ID, Firstname, Lastname, and Address.
they are placed into 1 column like this: IDFirstnameLastnameAddress

how can I split this up so the clipboard recognizes them as individual names?

What I have tried:

Tried to use a split function and adding a character in bewteen but that didnt work either.
Posted
Updated 20-Nov-17 12:50pm
v2
Comments
phil.o 20-Nov-17 16:21pm    
What is s variable? What exactly do you expect it to contain at the end? What is the use of the first for loop if you are not using the i variable? (both your loops seem to be redundant since they are functionnaly identical)
Member 11856456 20-Nov-17 18:24pm    
I have improved the code in the question, but it still isn't quite where I need it.

phil.o 20-Nov-17 18:36pm    
The clipboard does not "recognize" anything in itself, except maybe the type of content (text, image, file, etc...). The answer depends on where you want to paste the content of the clipboard: in a c# application, a simple string.Split("|") would do the trick; in Excel, for example, you would have to use your system list separator in order for Excel to interpret the data properly.
Member 11856456 20-Nov-17 18:40pm    
overall that is the main objective, I have made it further, but its not placing the information into the cells they belong in. How would I go about making it understand that the information needs to be separated into rows and columns?
phil.o 20-Nov-17 18:42pm    
Are you talking about Excel? You never mentioned it.

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900