0

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# :)

Edited by m1m6jbr

3
Contributors
2
Replies
15
Views
4 Years
Discussion Span
Last Post by ddanbe
0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.