Page 1 of 1

i need some c# help please

Posted: Tue Jan 02, 2007 4:59 pm
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 :)

Posted: Tue Jan 02, 2007 6:59 pm
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.

Posted: Tue Jan 02, 2007 7:50 pm
by stephen10101
thanks :D