Chat Contact List VB.NET and MSSQL(聊天联系人列表 VB.NET 和 MSSQL)
问题描述
我正在为我的工作制作一个聊天系统,但我很难找到一种方式来显示用户及其状态.
I'm making a chat system for my work and I'm having trouble to find a way to display users and their status.
所以我有一个叫做 Chat Client 的表单
So I have a Form called Chat Client
我有 Panel1(Left)
和 Panel2(Right)
在 Panel1
中,我必须让每个用户都列在我的数据库中
In Panel1
I have to get every user listed in my database
Select [first_name] + ' ' + [Name] As 'Contact', [Status] From dbo.TableUsers
这给出了以下内容:
[green image] [contact name] (if someone is logged in (status online))
[Orange image] [contact name] (If someone is logged in (status away))
[Red image] [contact name] (If someone is not logged in (Status offline))
如何创建一个下标,为我提供表中列出的所有用户,并在显示其状态的名称前附上一张图片?
How can I create a subscript that gives me all the users listed in the table with an image before the name showing their status?
推荐答案
我自己找到了答案 :)
I found the answer myself :)
我使用了带有 2 列的 e TableLayoutPanel,并用它填充了它:
i used e TableLayoutPanel with 2 columns and i filled it up with this:
While UserData.Read
If UserData("Status").ToString = "Online" 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 & "Pic"
ChatContactList.Controls.Add(newPictureBox)
Dim newLabel As New Label
newLabel.Text = UserData("Voornaam").ToString & " " & UserData("Achternaam").ToString
newLabel.Name = UserData("Username").ToString & "Lab"
newLabel.Font = New Font("Microsoft sans serif", 12)
newLabel.Height = 30
newLabel.AutoSize = True
newLabel.TextAlign = ContentAlignment.MiddleLeft
newLabel.Visible = True
ChatContactList.Controls.Add(newLabel)
ElseIf UserData("Status").ToString = "Afwezig" 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 & "Pic"
ChatContactList.Controls.Add(newPictureBox)
Dim newLabel As New Label
newLabel.Text = UserData("Voornaam").ToString & " " & UserData("Achternaam").ToString
newLabel.Name = UserData("Username").ToString & "Lab"
newLabel.Font = New Font("Microsoft sans serif", 12)
newLabel.Height = 30
newLabel.AutoSize = True
newLabel.TextAlign = ContentAlignment.MiddleLeft
newLabel.Visible = True
ChatContactList.Controls.Add(newLabel)
ElseIf UserData("Status").ToString = "Offline" Then
Dim newPictureBox As New PictureBox
newPictureBox.Image = My.Resources.ResourceManager.GetObject("redchat")
newPictureBox.Visible = True
newPictureBox.Width = 30
newPictureBox.Height = 30
newPictureBox.SizeMode = PictureBoxSizeMode.Zoom
newPictureBox.Name = UserData("Username").ToString & "Pic"
ChatContactList.Controls.Add(newPictureBox)
Dim newLabel As New Label
newLabel.Text = UserData("Voornaam").ToString & " " & UserData("Achternaam").ToString
newLabel.Name = UserData("Username").ToString & "Lab"
newLabel.Font = New Font("Microsoft sans serif", 12)
newLabel.Height = 30
newLabel.AutoSize = True
newLabel.TextAlign = ContentAlignment.MiddleLeft
newLabel.Visible = True
ChatContactList.Controls.Add(newLabel)
End If
End While
这篇关于聊天联系人列表 VB.NET 和 MSSQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:聊天联系人列表 VB.NET 和 MSSQL
基础教程推荐
- SQL Server 2016更改对象所有者 2022-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- Sql Server 字符串到日期的转换 2021-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01