Jump to content


Check out our Community Blogs

aazamsajid's Content

There have been 5 items by aazamsajid (Search limited from 29-February 20)


Sort by                Order  

#626071 Shorter code for tic-tac-toe game code

Posted by aazamsajid on 09 April 2012 - 10:45 AM in C#

when i apply is_row method this error is occrng.

An object reference is required for the non-static field, method, or property 'WindowsFormsApplication1.Form1.b'



#625923 Shorter code for tic-tac-toe game code

Posted by aazamsajid on 08 April 2012 - 11:50 AM in C#

i am working on a tic tac toe game this is loop code ....how can write this in short way like in algorthm or arrays etc

void check()
	    {
		    if (b[0].Text == b[1].Text && b[1].Text == b[2].Text && b[0].Text != "")//
		    {
			    MessageBox.Show(b[0].Text + " wins");
			    reset();
		    }
		    if (b[3].Text == b[4].Text && b[4].Text == b[5].Text && b[3].Text != "")//
		    {
			    MessageBox.Show(b[0].Text + " wins");
			    reset();
		    }
		    if (b[6].Text == b[7].Text && b[7].Text == b[8].Text && b[6].Text != "")//
		    {
			    MessageBox.Show(b[0].Text + " wins");
			    reset();
		    }
		    if (b[0].Text == b[3].Text && b[3].Text == b[6].Text && b[0].Text != "")//
		    {
			    MessageBox.Show(b[0].Text + " wins");
			    reset();
		    }
		    if (b[1].Text == b[4].Text && b[4].Text == b[7].Text && b[1].Text != "")//
		    {
			    MessageBox.Show(b[0].Text + " wins");
			    reset();
		    }
		    if (b[2].Text == b[5].Text && b[5].Text == b[8].Text && b[2].Text != "")//6
		    {
			    MessageBox.Show(b[0].Text + " wins");
			    reset();
		    }
		    if (b[0].Text == b[4].Text && b[4].Text == b[8].Text && b[0].Text != "")//7
		    {
			    MessageBox.Show(b[0].Text + " wins");
			    reset();
		    }
		    if (b[2].Text == b[4].Text && b[4].Text == b[6].Text && b[2].Text != "")//8
		    {
			    MessageBox.Show(b[0].Text + " wins");
			    reset();
		    }
		  
	   
	   
	    }



#625911 Change text size of a dynamic button

Posted by aazamsajid on 08 April 2012 - 09:53 AM in C#

bt.Font = new Font("Georgia", 16);

this is my solution...thx dear



#625909 Change text size of a dynamic button

Posted by aazamsajid on 08 April 2012 - 09:45 AM in C#

if i use this the following error occurng

1 Property or indexer 'System.Drawing.Font.Size' cannot be assigned to -- it is read only



#625904 Change text size of a dynamic button

Posted by aazamsajid on 08 April 2012 - 08:46 AM in C#

i am working on tic tac toe game and im creating dynamic buttions now i want change text's size of a dynamic buttion'text
how can i change ...?

void Form1_Click(object sender, EventArgs e)
	    {
		    Button bt = (Button)sender;
		    if (flag == 0)
		    {
			    bt.Text = "x";
			    bt.Text.Size = new System.Drawing.Size(30, 20);//this line i am using please correct it with a correct one.
			    flag = 1;
		    }
		    else
		    {
			    bt.Text = "0";
			    flag = 0;
		    }
		   
		    bt.Enabled = false;
		    t++;
		    check();
		    if (t == 9)
		    {
			    MessageBox.Show("Draw");
			    reset();
		    }
	    }




Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download