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.
Lines   Discription

1     Discription_1
2     Discription_2

Lines   Discription

1      Discription_1 & Discription_2

Thanx in advance
Who is Participating?
Jorge PaulinoConnect With a Mentor IT Pro/DeveloperCommented:
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 & " & "
        Me.DataGridView1.SelectedCells(0).Value = result.Remove(result.Length - 2)

Open in new window

BenvorAuthor Commented:
Thanx allot
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.