聊天联系人列表 VB.NET 和 MSSQL

Chat Contact List VB.NET and MSSQL(聊天联系人列表 VB.NET 和 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Execute complex raw SQL query in EF6(在EF6中执行复杂的原始SQL查询)
SSIS: Model design issue causing duplications - can two fact tables be connected?(SSIS:模型设计问题导致重复-两个事实表可以连接吗?)
SQL Server Graph Database - shortest path using multiple edge types(SQL Server图形数据库-使用多种边类型的最短路径)
Invalid column name when using EF Core filtered includes(使用EF核心过滤包括时无效的列名)
How should make faster SQL Server filtering procedure with many parameters(如何让多参数的SQL Server过滤程序更快)
How can I generate an entity–relationship (ER) diagram of a database using Microsoft SQL Server Management Studio?(如何使用Microsoft SQL Server Management Studio生成数据库的实体关系(ER)图?)