Listbox HELP ?

Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
13 posts Page 1 of 2
Contributors
User avatar
lesan101
Top Poster
Top Poster
Posts: 193
Joined: Tue Jun 29, 2010 8:10 am

Listbox HELP ?
lesan101
okay so im making a password saver program..
(because i dont want to continue using notepad to save my pass)

anyways im having an issue with the listbox.
i want everything to be organized...
example: everything spaced out equally, and lined up the same..


idk how to to that.. so this is what i get..
Image


i want to turn it into this (all organized)
Image

ANYONE..PLZ???
Image
User avatar
Scottie1972
Codenstuff Elite
Codenstuff Elite
Posts: 953
Joined: Thu Jan 14, 2010 5:48 am

Re: Listbox HELP ?
Scottie1972
forget the listbox...look into a ListView Control
Image
User avatar
lesan101
Top Poster
Top Poster
Posts: 193
Joined: Tue Jun 29, 2010 8:10 am

Re: Listbox HELP ?
lesan101
Scottie1972 wrote:
forget the listbox...look into a ListView Control
i rather use listbox.
Image
User avatar
bjm0008
Dedicated Member
Dedicated Member
Posts: 69
Joined: Thu Aug 13, 2009 2:35 am

Re: Listbox HELP ?
bjm0008
Download
http://www.mediafire.com/file/r2kgomjmy1j/Mngr.zip
OR
Mngr.zip
Define two integers, make sure they're Below PUBLIC CLASS FORM1!:
Code: Select all
Public Class Form1
    Public i As Integer = 0
    Dim i2 As Integer = 0
When you use 'Public' instead of 'Dim' the integer can be used with any form from this application.
In this case form2 will be adding to it.

Use Five(5) different Listboxes, One(1) Timer, One(1) Button, Four(4) Labels(rename correctly from below)
Image

Now add a new form. For begginners go to Project>Add Windows Form then press Ok.
Image

Now Make your Form look like this and ofcourse the top textbox is #1, below is #2, #3, #4 in order
Image

Time for the real coding:
Go back to form1 and double click or right click>ViewCode
Delete All Code and paste this:
Code: Select all
Public Class Form1
    Public i As Integer = 0
    Dim i2 As Integer = 0
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Timer1.Enabled = True
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Form2.Show()
        Form2.BringToFront()
        Form2.TopMost = True
        Me.Enabled = False
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If ListBox5.SelectedIndex > -1 Then
            ListBox1.SelectedIndex = ListBox5.SelectedIndex
            ListBox2.SelectedIndex = ListBox5.SelectedIndex
            ListBox3.SelectedIndex = ListBox5.SelectedIndex
            ListBox4.SelectedIndex = ListBox5.SelectedIndex
        End If
        Do Until ListBox5.Items.Count = i And i2 = i
            i2 = i2 + 1
            ListBox5.Items.Add(i2)
        Loop
    End Sub
End Class
Form2 Code:
Code: Select all
Public Class Form2

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Form1.ListBox1.Items.Add(TextBox1.Text)
        Form1.ListBox2.Items.Add(TextBox2.Text)
        Form1.ListBox3.Items.Add(TextBox3.Text)
        Form1.ListBox4.Items.Add(TextBox4.Text)
        Form1.i = Form1.i + 1
    End Sub

    Private Sub Form2_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Form1.Enabled = True
        Form1.BringToFront()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Close()
    End Sub
End Class
You do not have the required permissions to view the files attached to this post.
Image
User avatar
Livengood
Serious Programmer
Serious Programmer
Posts: 445
Joined: Tue Feb 16, 2010 6:24 am

Re: Listbox HELP ?
Livengood
lesan101 wrote:
Scottie1972 wrote:
forget the listbox...look into a ListView Control
i rather use listbox.
i can help you with this :), i have a way to use listbox like that :D

Edit :
are you talking something like this?
Account Saver.zip
You do not have the required permissions to view the files attached to this post.
Image
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: Listbox HELP ?
mandai
If it has to be all in one listbox you can seperate the values with a tab character.

Example:
Code: Select all
Dim index As Integer = ListBox1.Items.Add("value1" & vbTab & "value2" & vbTab & "value3")

Dim values As String() = ListBox1.Items(index).ToString().Split(vbTab)

MsgBox(values(0)) 'returns value1
User avatar
lesan101
Top Poster
Top Poster
Posts: 193
Joined: Tue Jun 29, 2010 8:10 am

Re: Listbox HELP ?
lesan101
Okay i was able to get it..
now all i need is how to save it the listbox ?
the windows to add the info is form1
the lisbox window is form2
Image
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: Listbox HELP ?
mandai
form2.ListBox1.Items.Add .. ?
User avatar
lesan101
Top Poster
Top Poster
Posts: 193
Joined: Tue Jun 29, 2010 8:10 am

Re: Listbox HELP ?
lesan101
mandai wrote:
form2.ListBox1.Items.Add .. ?
????
Image
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: Listbox HELP ?
mandai
What are you asking for exactly? Something to copy listbox items from one listbox to another?
13 posts Page 1 of 2
Return to “Tutorial Requests”