Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I make a list box with different colors for each item [ PART 1]

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    (Edited  )
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
[color green]Height = 4320
Keypreview = True
Width = 7200[/color]
2> Add a text box to the form, it's properties are these
[color green]Font = MS Sans Serif, 12 pt
Left = 120
Height = 375
Top = 210
Width = 3225[/color]
3>Add a check box to form, properties are these
[color green]Name = chklate
Caption = Overdue Books
Height = 285
Left = 555
Top = 1230
Width = 2385
Visible = False[/color]
4>Add a two command buttons, thier properties are
[color red]First Button[/color]
[color green]Name = butnew
Top = 3060
Left = 1080
Height = 315
Width = 1410
Caption = New[/color]
[color red] Second Button[/color]
[color green]Name = butchange
Caption = Save Changes
Height = 315
Left = 1080
Top = 3465
Width = 1410
Visible = False[/color]
5> Add a picture box with the following properties
[color green]Name = container
Height = 3735
Left = 3480
Top = 120
Width = 3540[/color]
6>Add a picture box [color red]inside of the other one[/color] properties are
[color green]Name = lst
AutoSize = True
Height = 4005
Left = -15
Top = -15
Width = 3240
Appearence = Flat
BackGround Color = White[/color]
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
[color green]Name = scr1
Height = 3675
Left = 3195
Top = 0
Width = 285[/color]
8>Add a label inside of the second picture box [ the white one]
[color green]Name = lstitem
Autosize = False
Caption = Example ListBox Item
Font = MS Sans Serif 12pt
Height = 22[/color]
[color red]Index = 0 //VERY IMPORTANT[/color]
[color green]Left = 0
Top = 1[/color]

[color red]Part Two has the actual code in it, I don't know how long these tutorials can be so I split it up[/color]
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top