I am trying to show some data from my mysql database in the flowlayoutpanel. I have created an UserControl with 3 diferent labels witch I need, Title, Message and Time. And i want to pass these 3 informations from my mysql query to the UserControl and then for each entry in my database create a seperate UserControl and output it in the FlowLAyoutPanel.
My UserControl Code:
Public Class ChatControl
Public _title As String
Public _message As String
Public _time As String
Public Property Title As String
Get
Return _title
End Get
Set(ByVal value As String)
_title = value
End Set
End Property
Public Property Message As String
Get
Return _message
End Get
Set(ByVal value As String)
_message = value
End Set
End Property
Public Property Time As String
Get
Return _time
End Get
Set(ByVal value As String)
_time = value
End Set
End Property
End Class
and this is my Form code:
Private Sub ChromeButton2_Click(sender As Object, e As EventArgs) Handles ChromeButton2.Click
Dim SDA As New MySqlDataAdapter
Dim dbDataSet As New Data.DataTable
Dim bSource As New BindingSource
Dim mysqlconn As New MySqlConnection(ConnectionString)
mysqlconn.Open()
Dim sqlcomand As String = "SELECT Text,
User,
Time
FROM call_center.DB_Script_Chat;"
command = New MySqlCommand(sqlcomand, mysqlconn)
SDA.SelectCommand = command
SDA.Fill(dbDataSet)
bSource.DataSource = dbDataSet
SDA.Update(dbDataSet)
For Each row As DataRow In dbDataSet.Rows
Dim myChat As New ChatControl()
myChat.Title = row.Item("User").ToString
myChat.Message = row.Item("Text").ToString
myChat.Time = row("Time").ToString
If FlowLayoutPanelChat.Controls.Count < 0 Then
FlowLayoutPanelChat.Controls.Clear()
Else
FlowLayoutPanelChat.Controls.Add(myChat)
End If
Next
End Sub
So the FlowLayoutPanel shows 3 entrys (becouse i have in my test database just 3 rows of data) but the data from the cells are not filled in the Title, Message and Time. It shows allways the defoult value i have set in the UserControl.
Please help. Thx