1 Replies - 319 Views - Last Post: 24 November 2012 - 07:52 AM Rate Topic: -----

#1 duggan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 23-November 12

Question about adding Form classes

Posted 24 November 2012 - 04:08 AM

Hi everyone.
Im new to this forum so i hold this is the right place to post this.
I have to make a web browser in C# for a college assignment and i have to have a calculator in it. I have the web browser and calculator made but i want to use to different form classes for each one. Ive made the web browser as the main form(Form1) and then i added a new form into it(Cal). I added a button on Form1 and i want it th button to open the calculator when you click on it. Here is the problem,I cant figure out how to make the button show the calculator when you click on it. Ive initialized the calculator form in Form1 but I dont know what to doe next? Can anyone help?

Code for Form1:
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WebBrowser
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        Cal calculator = new Cal();

        private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            TreeNode nName = e.Node;
            string webPage = "";

            webPage = (string)nName.Tag;

            if (webPage != "")
            {
                webBrowser1.Navigate(webPage);
            }
        }

        private void cal_Click(object sender, EventArgs e)
        {
            
        }
    }
}



Code for Calculator form(Cal):
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WebBrowser
{
    public partial class Cal : Form
    {
        public Form1 form;

        public Cal()
        {
            InitializeComponent();
        }
    }
}


I have also added a image of the form, well hopefully if i did it right.

Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: Question about adding Form classes

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6109
  • View blog
  • Posts: 23,666
  • Joined: 23-August 08

Re: Question about adding Form classes

Posted 24 November 2012 - 07:52 AM

I'm confused, but I've not done much dev in C# lately, particularly UI.

If you need to create a WebBrowser and load a Calculator into it, why would the calculator be a Windows Form? Wouldn't you be looking to implement the calculator as a web page?
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1