here is my code:

this is my select query where I concatenated the firstname, lastname, and middle initial..(and display it on the data grid)

  Private Sub DisplayListOfPosition()
    query = "SELECT profNo as 'No', CONCAT(profFName,', ', profLName, ' ', profMI,'.') as 'Name', profAddress 
    as 'Address', gender as 'Gender' FROM tbl_professor_bs"
    FillDBGrid(query, Me.dgvProfessor_bs)
    Me.txtProfNo_bs.Enabled = False
  End Sub

I used cellclick on the other forms so that the data in the grid would display in textboxes.. my problem is, how would I display the concatenated columns in different textboxes?
this is my code(unfinished):

Private Sub dgvProfessor_bs_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvProfessor_bs.CellClick
        DefaultValue()
        Me.txtProfNo_bs.Text = Me.dgvProfessor_bs.Rows(e.RowIndex).Cells(0).Value.ToString()
        Me.txtProfFName_bs.Text = Me.dgvProfessor_bs.Rows(e.RowIndex).Cells(1).Value.ToString()
    End Sub

thank you in advance for your help! :)

Recommended Answers

All 2 Replies

Hi,

You've concatenated the fields in your query and you want to split them back out again?

You could try using the split function on the space character:

dim Names() as String
....

Names = dgvProfessor_bs.Rows(e.Rowindex).Cells(1).Value.Split(New Char() {" "c})

textboxFirstName.Text = Replace(Replace(Names(0), ",",""),".","")
TextboxLastName.Text = Replace(Replace(Names(1),",",""),".","")
TextboxMiddle.Text = Replace(Replace(Names(2),",",""),".","")

thank you very much! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.