I want make if listbox item double click then message show with the content
Attachment 122341
How do I divide into 2 strings ?
[TIME] Is String 1
And after text [TIME] Is String 2
Printable View
I want make if listbox item double click then message show with the content
Attachment 122341
How do I divide into 2 strings ?
[TIME] Is String 1
And after text [TIME] Is String 2
You should really do this in an object orientated way. You add the object into the listbox, and take it back out.
Here is one method where we populate the ListBox with a DataTable, get information back then remove a row. I kept things simple which can easily be expanded upon.
Code:Private Sub LoadListBox()
Dim dt As New DataTable
dt.Columns.Add(New DataColumn With
{.ColumnName = "LeftSide", .DataType = GetType(String)})
dt.Columns.Add(New DataColumn With
{.ColumnName = "RightSide", .DataType = GetType(String)})
dt.Columns.Add(New DataColumn With
{.ColumnName = "DisplayText", .DataType = GetType(String),
.Expression = "LeftSide + ' ' + RightSide"})
dt.Rows.Add(New Object() {"[" & Now.ToString & "]", "A"})
ListBox1.DataSource = dt
ListBox1.DisplayMember = "DisplayText"
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
LoadListBox()
Dim dt As DataTable = CType(ListBox1.DataSource, DataTable)
dt.Rows.Add(New Object() {"[" & Now.AddHours(1).ToString & "]", "B"})
MessageBox.Show(CType(ListBox1.Items(0), DataRowView). _
Row.Field(Of String)("LeftSide").Replace("[", "").Replace("]", ""))
dt.Rows.RemoveAt(0)
End Sub