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
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