Goodmorning everybody,
here i am wanting to make a Login System that uses Usercontrol.
I have a label left
and right i have a panel.
in this panel i want to add usercontrol for all users that has one account in the application. this are some examples (Windos XP Login)
Image 1
Image 2
Image 3
How i have to start? thanks in advance!

Recommended Answers

All 8 Replies

You start by getting a list with valid users and for each user in the list show a different image (also a label with the username would be nice, just for when the users have the same image).
I think that I've seen a couple of examples in here about how to add controls dynamically during runtime.

PS: Make sure that your list doesn't contain too many users before becoming impractical to search for the appropriate account. (Like XP do when in AD).

See if this helps to get you started.
1.Panel

Public Class Form1
    Private arDummyUsers() As String = {"dummy 1", "dummy 2", "what the h.ll, another dummy xD"}

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        With Panel1
            .BackColor = Color.LightSteelBlue
            .AutoScroll = True '// Allows scrollbars if Controls are added and not .Visible.
        End With
        createCoolLoginDummies()
    End Sub

    Private Sub createCoolLoginDummies()
        Dim iCoolPictureBoxLocY As Integer = 5
        For Each dummyUser As String In arDummyUsers
            With Panel1.Controls
                .Add(New PictureBox With {.BorderStyle = BorderStyle.Fixed3D, .Width = 95, .Height = 95, .Left = 5, .Top = iCoolPictureBoxLocY})
                .Add(New Label With {.Text = dummyUser, .BorderStyle = BorderStyle.Fixed3D, .AutoSize = False, .Width = dummyUser.Length * 20, .Left = 100, .Top = iCoolPictureBoxLocY + 45})
            End With
            iCoolPictureBoxLocY += 100
        Next
        Panel1.Select()
    End Sub
End Class

Thank you so much to be here to help me, i will try it now!

Very nice it worked... Thank you so much, how can i align them to the center, and how can i change the

Private arDummyUsers() As String = {"dummy 1", "dummy 2", "dummy 3"}

with database(Database1DataSet) table(Users).

To change the users from "dummy" to "real...dummies?:D"(kidding), uhhmmm...:D

Instead of the For/Next loop that loops thru the arDummyUsers: For Each dummyUser As String In arDummyUsers use a loop similar to: For Each coolLoginUser As String In (Database1DataSet) table(Users) . I personally have no idea how to retrieve info from the db(database), though it seems like no issue for some to do.

>>how can i align them to the center
You can easily modify the .Location and everything else, by changing their Properties, as they are:

With Panel1.Controls
                .Add(New PictureBox With {.BorderStyle = BorderStyle.Fixed3D, .Width = 95, .Height = 95, .Left = 5, .Top = iCoolPictureBoxLocY})
                .Add(New Label With {.Text = dummyUser, .BorderStyle = BorderStyle.Fixed3D, .AutoSize = False, .Width = dummyUser.Length * 20, .Left = 100, .Top = iCoolPictureBoxLocY + 45})
            End With

...it just takes a bit of patience to get the results you want, If Not greater.:)

i tried with this source:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'Database1DataSet1.Tabella1' table. You can move, or remove it, as needed.
        Me.Tabella1TableAdapter.Fill(Me.Database1DataSet1.Tabella1)
        With Panel1
            .BackColor = Color.White
            .AutoScroll = True '// Allows scrollbars if Controls are added and not .Visible.
        End With
        createCoolLoginDummies()
    End Sub

    Private Sub createCoolLoginDummies()
        Dim iCoolPictureBoxLocY As Integer = 5
        Dim UserTitle As String = Database1DataSet1.Tabella1.TitleColumn.ToString
        Dim UserPass As String = Database1DataSet1.Tabella1.PassColumn.ToString
        For Each coolLoginUser As String In Database1DataSet1.Tabella1.ToString
            With Panel1.Controls
                .Add(New PictureBox With {.BorderStyle = BorderStyle.Fixed3D, .Width = 95, .Height = 95, .Left = 5, .Top = iCoolPictureBoxLocY})
                .Add(New Label With {.Text = UserTitle, .BorderStyle = BorderStyle.Fixed3D, .AutoSize = False, .Width = UserTitle.Length * 20, .Left = 100, .Top = iCoolPictureBoxLocY + 30})
                .Add(New TextBox With {.Text = "Write the password", .BorderStyle = BorderStyle.Fixed3D, .AutoSize = True, .Width = 120, .Left = 100, .Top = iCoolPictureBoxLocY + 60})
            End With
            iCoolPictureBoxLocY += 100
        Next
        Panel1.Select()
    End Sub

but this don't works well, because this continue show me the "TitleColumn", not the element of the Title Column

Wish I could be of further.support, though hobbyist.programmer here and db isNot a hobby, it's business; and the best part is, it's none of my god dam.n business.:D

Good luck and glad that you are at least getting "some" results.:)

Wanted to add; Try searching for how to get "elements?" of the Title Column, and If no luck, start a new thread. Catch ex as Message no.msg'es here End Try

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.