المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : error in passing value from one form to other



C# Programming
02-14-2011, 02:31 AM
I am using c# window application. I am trying to pass the value of variable from one form to other. But it is giving error:Can any one correct this? thanks in advance.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Threading;

namespace WindowsApplication1

{

public partial class Form1 : System.Windows.Forms.Form
{

public string frm1;

Form2 f = new Form2();

private string stringOnForm1;
public Form1(string sTEXT)
{
InitializeComponent();
textBox1.Text = sTEXT;



}





private void Form1_Load(object sender, EventArgs e)
{


f.Show();
f.button2.Visible = false;
Random rand = new Random();

Color[] c = { Color.Green, Color.Red };
// Thread.Sleep(1000);

this.button1.BackColor = c[rand.Next(0, c.Length)];
this.button2.BackColor = c[rand.Next(0, c.Length)];

if (this.button1.BackColor == Color.Red && this.button2.BackColor != Color.Red)
{


// Thread.Sleep(1000);
f.button2.Visible = true;
f.s = "1 Message received";
f.s1 = "ur gas is being leaked";

}

else if (this.button2.BackColor == Color.Red && this.button1.BackColor != Color.Red)
{
//Thread.Sleep(1000);
f.button2.Visible = true;
f.s = "1 Message received";
f.s1 = "ur electric is being leaked";

}

else if (this.button1.BackColor == Color.Red && this.button2.BackColor == Color.Red)
{
//Thread.Sleep(1000);
f.button2.Visible = true;
f.s = "2 Messages received";
f.s1 = "ur electric and gas is being leaked";

}








}



private void button1_Click(object sender, EventArgs e)
{


}

private void button2_Click(object sender, EventArgs e)
{

}

private void label2_Click(object sender, EventArgs e)
{

}

private void textBox1_TextChanged(object sender, EventArgs e)
{

}

} }

Error:
No overload for method 'Form1' takes '0' arguments