Combine rows in a DataGrid

Hi Experts

I have a Datagrid(DataGridView1) which I use to populate a Access query. I want a user to be able to select two lines and then click on a button that combines the text from both lines together.
ex:
Lines   Discription

1     Discription_1
2     Discription_2

<<AFTER COMBINE>>
Lines   Discription

1      Discription_1 & Discription_2

Thanx in advance
BenvorAsked:
Who is Participating?
 
Jorge PaulinoConnect With a Mentor IT Pro/DeveloperCommented:
Hi,
You can try something like this to combine the strings:

        Dim result As String = String.Empty
        For Each cell As DataGridViewCell In Me.DataGridView1.SelectedCells
            result &= cell.Value.ToString & " & "
        Next
 
        Me.DataGridView1.SelectedCells(0).Value = result.Remove(result.Length - 2)

Open in new window

0
 
BenvorAuthor Commented:
Thanx allot
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.