JohnDW
Well-known member
Hello,
I'm working on a code to fill a listbox with data from a datagridview and be able copy to clipboard.
The code I have:
This code works, but it gives me every storeanswer on another line.
I'm looking for a way to write storeanswer on one line , fill it with 50 storeanswer seperated by a semicolon,
and go to the next line, fill it again with 50 untel endAt.
I was looking on the net, but couldn't find an way to do it.
Then I want to Copy it to the clipboard .
Therefore I set SelectionMode.MultiExtended
I found the following code on the net
But this code don't work.
Some hints?
John
I'm working on a code to fill a listbox with data from a datagridview and be able copy to clipboard.
The code I have:
VB.NET:
Dim endAt As Integer
Dim StoreAnswer As String
Dim i As Integer
endAt = CInt(DataGridView1.RowCount - 1)
Dim StoredAnswers(endAt) As String
For i = 0 To endAt
StoreAnswer = CStr(DataGridView1.Rows(i).Cells(2).Value)
i = i + 1
ListBox1.Items.Add(StoreAnswer & ";")
Next i
This code works, but it gives me every storeanswer on another line.
I'm looking for a way to write storeanswer on one line , fill it with 50 storeanswer seperated by a semicolon,
and go to the next line, fill it again with 50 untel endAt.
I was looking on the net, but couldn't find an way to do it.
Then I want to Copy it to the clipboard .
Therefore I set SelectionMode.MultiExtended
I found the following code on the net
VB.NET:
[FONT=Consolas][SIZE=2] Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ListBox1.KeyDown
If e.Control AndAlso e.KeyCode = Keys.C Then
Dim copy_buffer As New System.Text.StringBuilder
For Each item As Object In ListBox1.SelectedItems
copy_buffer.AppendLine(item.ToString)
Next
If copy_buffer.Length > 0 Then
Clipboard.SetText(copy_buffer.ToString)
MessageBox.Show("Copied Items to Clipboard")
End If
End If
End Sub
[/SIZE][/FONT]
But this code don't work.
Some hints?
John
Last edited: