I HVE make class in one form of windows application..n want to call that class in 2nd form of windows application tools that is in button ..so can u plzz tell me the coding as soon as possible..its urgent...

You need to create an instance of that class. Write following code in button's click handler.

ClassName var=new ClassName();

In case you are using namespace then use,

namespace_Name.ClassName var=new namespace_Name.ClassName();

listen it is generating an error Error.........The type or namespace name 'namespace_Name' could not be found (are you missing a using directive or an assembly reference?)???????????????reply me fast

Well you surely miss some namespace in your application.......
thats why this error is coming........

as i am using namespace windows application??????????????it is generating an Error.........The type or namespace name 'namespace_Name' could not be found (are you missing a using directive or an assembly reference?)???????????????
by using ur code...... namespace_Name.ClassName var=new namespace_Name.ClassName();........................reply me fast

Well you surely miss some namespace in your application.......
thats why this error is coming........

in headers??????as i hve mention above...namespace windows application??????

well i already told you that you are missing any namespace in your application.........
Just add that missing namespace, this error will resolve automatically...........

I have make class in one form of windows application..n want to call that class in 2nd form of windows application tools that is in button ..so can u plzz tell me the coding as soon as possible..its urgent...

I have done this coding plz guide me where shoul I add namespace.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication2
{
    public partial class Form5 : Form
    {
        int zoom1 = 0;
        public Form5(String image)
        {

            InitializeComponent();
            Bitmap b = new Bitmap(image);
            pictureBox1.Image = b;
        }

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

        private void button1_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (zoom1 >= 0 && zoom1 <= 4)
            {
                pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                pictureBox1.Width += 150;
                pictureBox1.Height += 150;
                zoom1++;
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {

            if (zoom1 > 0)
            {
                pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                pictureBox1.Width -= 150;
                pictureBox1.Height -= 150;
                zoom1--;
            }

        }

        private void Form5_Load(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Maximized;
        }

        private void button5_Click(object sender, EventArgs e)
        {
            ActiveForm.Hide();
            Form6 f = new Form6();
            f.Show();

        }

        private void button4_Click(object sender, EventArgs e)
        {
            namespace_Name.ClassName var=new namespace_Name.info_db();
        }
    }
}

any idea!!!!!!!!!!!!

xtremebeauty,

First of all I suggest you to use code tags to post source code. If any confusion about code tags, please read - How to use code tags?.

In my post #2 I have posted an example - How to instantiate a class (How to create an object)? You have to write a code something like that (I missed to pointed out earlier in that post).

And here is your question,

I HVE make class in one form of windows application..n want to call that class in 2nd form of windows application tools that is in button ...

I presume that you have a class named "Test" in your window application and you want to invoke a method of Test class; use following syntax.

ClassName objvar=new ClassName();

Consider the following example,

public class Test{
   public void Print(){
     MessageBox.Show("Sample");
  }
}

To invoke a Print method of Test class,

Test obj1=new Test();
 obj1.Print();
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication2
{
    public partial class Form5 : Form
    {
        int zoom1 = 0;
        public Form5(String image)
        {

            InitializeComponent();
            Bitmap b = new Bitmap(image);
            pictureBox1.Image = b;

        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (zoom1 >= 0 && zoom1 <= 4)
            {
                pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                pictureBox1.Width += 150;
                pictureBox1.Height += 150;
                zoom1++;

            }
        }

        private void button3_Click(object sender, EventArgs e)
        {

            if (zoom1 > 0)
            {
                pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                pictureBox1.Width -= 150;
                pictureBox1.Height -= 150;
                zoom1--;
            }


        }

        private void Form5_Load(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Maximized;

        }

        private void button5_Click(object sender, EventArgs e)
        {
            ActiveForm.Hide();
            Form6 f = new Form6();
            f.Show();

        }

        private void button4_Click(object sender, EventArgs e)
        {
         WindowsApplication2.info_db var = new WindowsApplication2.info_db();
            
        }

now tell me wt should i do to print my result...as u know my prob that my class is in one form n i want to call that class funct in 2nd form tools i.e button.

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.