0

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!

3
Contributors
8
Replies
10
Views
5 Years
Discussion Span
Last Post by codeorder
0

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).

0

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

Edited by codeorder: went bold

0

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).

0

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.:)

Edited by codeorder: n/a

0

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

0

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.:)

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.