Sunday, July 12, 2009

In C# how can i set the background color of a form with code? Read details.?

I am trying to set the background color of a form to a color i have created which will change randomly.


I have tried saying:


Form1 joe = new Form1();


joe.backColor = Color.red;





that didnt work.

In C# how can i set the background color of a form with code? Read details.?
I don't see any problem in your code. It should work provided that Form1 is a control that inherits the class FORM. Can you explain why it's not working. Are getting any error. Is the debugger complaining?
Reply:how about a .refresh ?


This code does the job, and does not need a refresh.





namespace WindowsApplication1


{


public partial class Form1 : Form


{


public Form1()


{


InitializeComponent();


this.BackColor = Color.Red;


// this.Refresh();


}


}


}
Reply:i don't understand these words. im very sorry

jasmine

No comments:

Post a Comment