INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Visual Basic (Microsoft) Versions 5/6 FAQ

What VB shoud be able to do!

How do I make a list box with different colors for each item [ PART 1] by DarkMercenary44
Posted: 21 Nov 00

I made this list box because I've seen it in so many places that people ask how to do this.  Well, I'm just a beginner , and this is what I came up with, its not very complicated code, not long either.  ChrisTina requested that the list box show people's names and the ones that had over due library books where shown in red.  So here is what I made for her/him [sorry not sure with the name]

I'm going to have you make an exact duplicate of the one that is on my computer that way I know it works, right down to the size and position of the controls.

1>Start a new project, with the form set its properties to these
    Height = 4320
    Keypreview = True
    Width = 7200

2> Add a text box to the form, it's properties are these
    Font = MS Sans Serif, 12 pt
    Left = 120
    Height = 375
    Top = 210
    Width = 3225

3>Add a check box to form, properties are these
    Name = chklate
    Caption = Overdue Books
    Height = 285
    Left = 555
    Top = 1230
    Width = 2385
    Visible = False

4>Add a two command buttons, thier properties are
    First Button
    Name = butnew
    Top = 3060
    Left = 1080
    Height = 315
    Width = 1410
    Caption = New

     Second Button
    Name = butchange
    Caption = Save Changes
    Height = 315
    Left = 1080
    Top = 3465
    Width = 1410
    Visible = False

5> Add a picture box with the following properties
    Name = container
    Height = 3735
    Left = 3480
    Top = 120
    Width = 3540

6>Add a picture box inside of the other one properties are
    Name = lst
        AutoSize = True
    Height = 4005
    Left = -15
    Top = -15
    Width = 3240
    Appearence = Flat
    BackGround Color = White

7>Add a Vertical Scroll Bar inside of first picture box, you should see a little space left for it if you used all of my values, the properties are
    Name = scr1
    Height = 3675
    Left = 3195
    Top = 0
    Width = 285

8>Add a label inside of the second picture box [ the white one]
    Name = lstitem
    Autosize = False
    Caption = Example ListBox Item
    Font = MS Sans Serif 12pt
    Height = 22

    Index = 0   //VERY IMPORTANT
    Left = 0
    Top = 1


Part Two has the actual code in it, I don't know how long these tutorials can be so I split it up

Back to Visual Basic (Microsoft) Versions 5/6 FAQ Index
Back to Visual Basic (Microsoft) Versions 5/6 Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close