我正在从MSsql加载这个列表但是当我重新加载列表时它会闪烁.
此列表是一个带有动态创建的图片框和标签的TableLayoutPanel.
我的问题是:
当您重新加载我的联系人而不是重新加载整个列表时,如何在动态图片框中更改我的图像.
我创建表的代码:
While UserData.Read If UserData("Status").ToString = "Online" Then If UserData("NieuwBericht").ToString = "Ja" Then Dim newPictureBox As New PictureBox newPictureBox.Image = My.Resources.greenchat newPictureBox.Visible = True newPictureBox.Width = 30 newPictureBox.Height = 30 newPictureBox.SizeMode = PictureBoxSizeMode.Zoom newPictureBox.Name = UserData("Username").ToString ChatContactList.Controls.Add(newPictureBox) Dim newPictureBox2 As New PictureBox newPictureBox2.Image = My.Resources.greenbubblechat newPictureBox2.Visible = True newPictureBox2.Width = 30 newPictureBox2.Height = 30 newPictureBox2.SizeMode = PictureBoxSizeMode.Zoom newPictureBox2.Name = UserData("Username").ToString ChatContactList.Controls.Add(newPictureBox2) Dim newLabel As New Label AddHandler newLabel.Click,AddressOf ChatBox newLabel.Text = UserData("Voornaam").ToString & " " & UserData("Achternaam").ToString newLabel.Name = UserData("Username").ToString newLabel.Font = New Font("Microsoft sans serif",12) newLabel.Dock = DockStyle.Fill newLabel.TextAlign = ContentAlignment.MiddleLeft newLabel.Visible = True ChatContactList.Controls.Add(newLabel) ElseIf UserData("NieuwBericht").ToString = "Nee" Then Dim newPictureBox As New PictureBox newPictureBox.Image = My.Resources.greenchat newPictureBox.Visible = True newPictureBox.Width = 30 newPictureBox.Height = 30 newPictureBox.SizeMode = PictureBoxSizeMode.Zoom newPictureBox.Name = UserData("Username").ToString ChatContactList.Controls.Add(newPictureBox) Dim newPictureBox2 As New PictureBox newPictureBox2.Image = My.Resources.greybubblechat newPictureBox2.Visible = True newPictureBox2.Width = 30 newPictureBox2.Height = 30 newPictureBox2.SizeMode = PictureBoxSizeMode.Zoom newPictureBox2.Name = UserData("Username").ToString ChatContactList.Controls.Add(newPictureBox2) Dim newLabel As New Label AddHandler newLabel.Click,12) newLabel.Dock = DockStyle.Fill newLabel.TextAlign = ContentAlignment.MiddleLeft newLabel.Visible = True ChatContactList.Controls.Add(newLabel) End If ElseIf UserData("Status").ToString = "Afwezig" Then If UserData("NieuwBericht").ToString = "Ja" Then Dim newPictureBox As New PictureBox newPictureBox.Image = My.Resources.orangechat newPictureBox.Visible = True newPictureBox.Width = 30 newPictureBox.Height = 30 newPictureBox.SizeMode = PictureBoxSizeMode.Zoom newPictureBox.Name = UserData("Username").ToString ChatContactList.Controls.Add(newPictureBox) Dim newPictureBox2 As New PictureBox newPictureBox2.Image = My.Resources.greenbubblechat newPictureBox2.Visible = True newPictureBox2.Width = 30 newPictureBox2.Height = 30 newPictureBox2.SizeMode = PictureBoxSizeMode.Zoom newPictureBox2.Name = UserData("Username").ToString ChatContactList.Controls.Add(newPictureBox2) Dim newLabel As New Label AddHandler newLabel.Click,12) newLabel.Dock = DockStyle.Fill newLabel.TextAlign = ContentAlignment.MiddleLeft newLabel.Visible = True ChatContactList.Controls.Add(newLabel) ElseIf UserData("NieuwBericht").ToString = "Nee" Then Dim newPictureBox As New PictureBox newPictureBox.Image = My.Resources.orangechat newPictureBox.Visible = True newPictureBox.Width = 30 newPictureBox.Height = 30 newPictureBox.SizeMode = PictureBoxSizeMode.Zoom newPictureBox.Name = UserData("Username").ToString ChatContactList.Controls.Add(newPictureBox) Dim newPictureBox2 As New PictureBox newPictureBox2.Image = My.Resources.greybubblechat newPictureBox2.Visible = True newPictureBox2.Width = 30 newPictureBox2.Height = 30 newPictureBox2.SizeMode = PictureBoxSizeMode.Zoom newPictureBox2.Name = UserData("Username").ToString ChatContactList.Controls.Add(newPictureBox2) Dim newLabel As New Label AddHandler newLabel.Click,12) newLabel.Dock = DockStyle.Fill newLabel.TextAlign = ContentAlignment.MiddleLeft newLabel.Visible = True ChatContactList.Controls.Add(newLabel) End If ElseIf UserData("Status").ToString = "Offline" Then If UserData("NieuwBericht").ToString = "Ja" Then Dim newPictureBox As New PictureBox newPictureBox.Image = My.Resources.redchat newPictureBox.Visible = True newPictureBox.Width = 30 newPictureBox.Height = 30 newPictureBox.SizeMode = PictureBoxSizeMode.Zoom newPictureBox.Name = UserData("Username").ToString ChatContactList.Controls.Add(newPictureBox) Dim newPictureBox2 As New PictureBox newPictureBox2.Image = My.Resources.greenbubblechat newPictureBox2.Visible = True newPictureBox2.Width = 30 newPictureBox2.Height = 30 newPictureBox2.SizeMode = PictureBoxSizeMode.Zoom newPictureBox2.Name = UserData("Username").ToString ChatContactList.Controls.Add(newPictureBox2) Dim newLabel As New Label AddHandler newLabel.Click,12) newLabel.Dock = DockStyle.Fill newLabel.TextAlign = ContentAlignment.MiddleLeft newLabel.Visible = True ChatContactList.Controls.Add(newLabel) ElseIf UserData("NieuwBericht").ToString = "Nee" Then Dim newPictureBox As New PictureBox newPictureBox.Image = My.Resources.redchat newPictureBox.Visible = True newPictureBox.Width = 30 newPictureBox.Height = 30 newPictureBox.SizeMode = PictureBoxSizeMode.Zoom newPictureBox.Name = UserData("Username").ToString ChatContactList.Controls.Add(newPictureBox) Dim newPictureBox2 As New PictureBox newPictureBox2.Image = My.Resources.greybubblechat newPictureBox2.Visible = True newPictureBox2.Width = 30 newPictureBox2.Height = 30 newPictureBox2.SizeMode = PictureBoxSizeMode.Zoom newPictureBox2.Name = UserData("Username").ToString ChatContactList.Controls.Add(newPictureBox2) Dim newLabel As New Label AddHandler newLabel.Click,12) newLabel.Dock = DockStyle.Fill newLabel.TextAlign = ContentAlignment.MiddleLeft newLabel.Visible = True ChatContactList.Controls.Add(newLabel) End If End If End While
我的联系人名单的图片