i need some c# help please

Post here about scripting and programming for HaloPC (audio, network, ai, etc.)
Post Reply
stephen10101





Posts: 140
Joined: Sat Jul 29, 2006 9:11 pm
Location: Klein, TX

i need some c# help please

Post by stephen10101 »

how would i code for different stuff to happen if a checkbox is checked and then a button is pressed, like if one is checked a message boxe will come up and say something? please help, im starting with the basics of c# because i want to start making modding programs and i think c# would be the language of choice. thank you :)
i dont want a sig!
an emu





Posts: 280
Joined: Fri Feb 18, 2005 5:16 pm
Location: a box under the freeway

Post by an emu »

For this, and many problems in coding, you will want to use an "If, Then" statement. I have written a sample of code that shows you how to implement this in C#

Code: Select all

        private void button1_Click(object sender, EventArgs e)
        {
            if (checkBox1.Checked == true)
                if (checkBox2.Checked==true)
                    MessageBox.Show("You checked Checkbox1 and 2");
                else
                MessageBox.Show("You checked Checkbox1");
            else if (checkBox2.Checked == true)
                MessageBox.Show("You checked Checkbox2");
            else
                MessageBox.Show("No Checkbox was checked");
                
        }
Assuming you have objects named button1, checkbox1, and checkbox2, this will find which checkboxes are checked, if any, and pop up a message box that tells you which box is checked. For more help with C#, watch the video tutorials on the MSDN website, they are a great starting point.
Last edited by an emu on Tue Jan 02, 2007 10:00 pm, edited 1 time in total.
stephen10101





Posts: 140
Joined: Sat Jul 29, 2006 9:11 pm
Location: Klein, TX

Post by stephen10101 »

thanks :D
i dont want a sig!
Post Reply