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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

permanently change backcolor of label

Status
Not open for further replies.

datamasher

Technical User
Dec 31, 2001
69
GB
Hi everyone,
I have a form with small labels on to represent a theatre seating plan. Each label represents a seat number eg. A1, A2 etc. I want to permanently change a label's backcolor from green to red by clicking on it, thus indicating the ticket for that seat has been sold. I set the backcolor of the label to green at design time.

I know how to change the backcolor using the following code :
Note :: this code is in fact VB 2008 express but it is very similar to VB6 ::

Code:
Public Class Form1

    Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.Click
        Label3.BackColor = Color.Red
    End Sub
End Class
and indeed the backcolor changes to red but, as I suspected, if I close the form and then re-open it at a later stage the label backcolor has reverted back to green.

How can I make hold it's new backcolor of red permanently, or is this not possible?

I originally posted in VB6 forum but was kindly directed here with a suggestion that I could use system settings to do this. Have tried, but cannot get the hang of it

Steve
 
Hmm. you could also write to a text file when you change the color. in this file I would write the seat number and a flag indicating whether or not the seat was sold. Then when you start the program, read the file into your program with the value of the flag for each seat. Check to see if the seat is sold, change the color if it is.

This is one way to do it. You could also set up a database to do the sam thing. But this might be a bit of overkill.
 
Options..
1. Text file
2. Database
3. INI file
4. Registry
...

________________________________________________________
Zameer Abdulla
Help to find Missing people
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top