Copy Paste datagridView Row - how to assign value to comboBox colu

N

NetNewbie

Hi I have the following code in a button click event to copy and paste a
selected datagridview Row. The grid has textbox, checkbox and combobox. Can
anyone please tell me how to assign the value to a combo box? The combo box
and DGV are databound. The combobox has a display member and value member.
When I copy the DGV row, the operation copies the whatever is displayed in
the combobox (ie., the display member value). If I try to assign the same to
the combobox, then an error occurs and goes into an infinite loop.

Clipboard.SetDataObject(Me.MailDescriptionL3DataGridView.GetClipboardContent().GetData(DataFormats.Text))

'Create a new row
Me.MailDescriptionL3BindingSource.AddNew()

'Paste the copied row values
strDGVRow = Clipboard.GetText
strRowCell = Split(strDGVRow, " ") 'split character is a tab

j = MailDescriptionL3DataGridView.CurrentRow.Index
'Since the first value is an empty string, I start my loop at 1.
For i = 1 To strRowCell.Length - 5 'donot copy the last 4
fields
MailDescriptionL3DataGridView.Rows(j).Cells(i -
1).Value = strRowCell(i)
End If
Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top