Hey,

I have 3 listboxes linked together that display 3 different fields of a table from an acess database. THe listindexs are set to equal each other so when you click on one it highlights on them all. However when the listbox gets lots of records in it, vertical scroll bars appear on all three. Is there away to remove these and have one big vertical scroll bar on the side.

Thanks

Hi,

There is no way to remove the Scroll Bar of the List box If the Items are exceeding the Physical height of List Box.

Use a single List Box and Show records in a Formatted Order.
Like First 20 Char Field1, Next 20 Char Field 2, and
Next 20 Char Field 3.

Or else use 3 different Combo Boxes.

Instead of using List Box, u can use a Flex grid Control Or a
ListView Control .

Regards
Veena

Hey,

Ive looked at listview before but i didnt know how to populate it with info from a database, which is easy to do with a listbox

Any idea how?

Thanks

Hey,

I have 3 listboxes linked together that display 3 different fields of a table from an acess database. THe listindexs are set to equal each other so when you click on one it highlights on them all. However when the listbox gets lots of records in it, vertical scroll bars appear on all three. Is there away to remove these and have one big vertical scroll bar on the side.

Thanks

why don't you use a grid control instead of three list boxes?

Hi,

Use This Code To Populate ListView.
Assuming Recordset RS is open.
In Property Sheet Set lvw.View =3

Dim i As Long
   Dim TItem As ListItem
    With lvw
        .ListItems.Clear
        .ColumnHeaders.Clear
        .ColumnHeaders.Add , , "SlNo", 800
        .ColumnHeaders.Add , , "Field1",1500
        .ColumnHeaders.Add , , "Field2",1500
        .ColumnHeaders.Add , , "Field3",1500
    End With
    i=0
    RS.MoveFirst
    Do While Not RS.EOF
        i=i+1
        With lvw
            Set TItem = .ListItems.Add(Key:="X" & i, text:=i)
            TItem.ListSubItems.Add Key:="Field1", text:=RS("Field1")
            TItem.ListSubItems.Add Key:="Field2", text:=RS("Field2")
            TItem.ListSubItems.Add Key:="Field3", text:=RS("Field3")
    RS.MoveNext
    Loop

I hope It is Clear

Regards
Veena

Hi,

Sorry in above code,

Before RS.MoveNext
Give End With

Hey,

Code works well but i was wondering some things.

With the listboxes i sorted them by ID which is an autonumber in the database. Like so

List1.AddItem rstRecordSet!fname
        List1.ItemData(List1.NewIndex) = rstRecordSet!id

So then when you click on it and then click anothe rbutton it opens a new form with more details on that person, using the id to get the right person.

Can this be done using listview?

Hi,

While Populating the List View, give Key this way :

Dim MyID As Long
MyID = rstRecordSet!id
Set TItem = .ListItems.Add(Key:="X" & MyID, text:=MyID)
 
Or 
 
Add One More Sub Item (like Field1)

Regards
Veena

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.