hello

i'have a problem using multiple form

the Form1
is the main form

and Form2 , the Form that the user will insert data in, and then these data must appear at Form1

this is my code :)

 public partial class Form1 : Form
    {
        public Form3 ff = new Form3();
        public double pricee;
        public Form1()
        {
            InitializeComponent(); 
        }
        private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

            if (checkedListBox1.GetItemChecked(checkedListBox1.SelectedIndex))
            {
                ff.Show();

                if (ff.button1.Equals("button1"))
                {
                    listBox3.Items.Add("hello");
                    label6.Text = "hello";
                }
            }
            else
            {
                listBox2.Items.Remove(checkedListBox1.SelectedItem);
            }

        }

Form2 :

public partial class Form2 : Form
    {
        private double price;

        public Form2()
        {
            InitializeComponent();

        }

        private void button1_Click(object sender, EventArgs e)
        {
            Form1 f = new Form1();

            if (textBox1.Text.Equals(""))
                MessageBox.Show("insert a numeric value");
            else
            {
                 price = double.Parse(textBox1.Text);
                 this.Hide();
            }
            return;
        }
        public  double getP() 
        {
            return price;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Hide();
        }

i'am a new in c# :)

Recommended Answers

All 2 Replies

niether understand your question nor code
which data do you want to show on form2

Line 3 will not compile, because Form3 does not exist.
Did you mean public Form ff = new Form();
or public Form Form3 = new Form(); ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.