Computing.Net > Forums > Programming > Help with C# again... :P

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Help with C# again... :P

Reply to Message Icon

Name: El-Trucha
Date: March 18, 2005 at 13:46:53 Pacific
OS: Windows XP SP2
CPU/Ram: 2.8 GHz/448 MB
Comment:

Hello every1!! :D
OK...I made a form in C# with some checkboxes...for example, 1 of the checkboxes says "Mustard", and when the user checks it, it's supposed to add $0.50 to a label, the problem is that where do I put the code to see if the checkbox was pressed?? do I put it after the InitializeComponent call?? where??
Thanx!! ;)

El-Trucha
http://www.truchasoft.tk
ftp://tsfc.homeftp.net
hotline://tsfc.ath.cx



Sponsored Link
Ads by Google

Response Number 1
Name: El-Trucha
Date: March 18, 2005 at 19:06:48 Pacific
Reply:

Neeeeeeeevermind...what an idiot, I just had 2 double-click it in the IDE... :@ :P
But now, I have 1 more prob:

Again with the public thing...but this time, here's the problem:
Price BurgerPrice = new Price();
I'm putting that inside the InitializeComponent(), just before setting the Text property of a control...
The problem is that, in the _CheckedChanged() method of another control, I try to call the BurgerPrice object, and I get an error just as if I'd never declared it... :(
What can I do now?? thanx! ;)

El-Trucha
http://www.truchasoft.tk
ftp://tsfc.homeftp.net
hotline://tsfc.ath.cx


0

Response Number 2
Name: Chi Happens
Date: March 18, 2005 at 20:48:12 Pacific
Reply:

You need to learn about scope. An object's scope determines who can access it.

If you want BurgerPrice accessable to all members of a class you can define it as a private member at the top of the class definition:

Public class MyClass
{
    private Price BurgerPrice = new Price();
    Public MyClass()
    {
    }
}

If you want BurgerPrice to be accessible to other classes you can make it public, or better yet, keeping in line with ADT rules (ADT = Abstract Data Type) you should make getters and setters for that property:

Public class MyClass
{
    Private Price BurgerPrice = new Price();
    Public MyClass()
    {
    }
    Public Price burgerPrice
    {
        get
        {
            return BurgerPrice;
        }
        set
        {
            BurgerPrice = value;
        }
    }
}

Hope this helps you some. You might want to pick up C# How To Program by Dietel (they are really good books...I own the C++ How to program one and I highly recommend it too)

Chi

They mostly come at night...mostly


0

Response Number 3
Name: El-Trucha
Date: March 18, 2005 at 23:09:45 Pacific
Reply:

Yay!! that worked!! thanx!! ;)
Well, I got Microsoft Visual C# .NET by Joyce Farrell, which I got from a very expensive mail-in course...I'm almost finishing the book... :)
Thanx!! ;)

El-Trucha
http://www.truchasoft.tk
ftp://tsfc.homeftp.net
hotline://tsfc.ath.cx


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Help with C# again... :P

Please help with c on bowling probl www.computing.net/answers/programming/please-help-with-c-on-bowling-probl/6979.html

Need help with C++ program www.computing.net/answers/programming/need-help-with-c-program/19441.html

Help with c programming! www.computing.net/answers/programming/help-with-c-programming/9893.html