No overload for method 'MainForm' takes '0' arguments

  • (2 Pages)
  • +
  • 1
  • 2

15 Replies - 37992 Views - Last Post: 21 October 2008 - 01:43 PM Rate Topic: -----

#1 webwired  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 33
  • View blog
  • Posts: 339
  • Joined: 26-August 07

No overload for method 'MainForm' takes '0' arguments

Post icon  Posted 20 October 2008 - 08:51 AM

I've been searching and searching around for a solution to this problem, but everything I read leads me to think that there isn't anything wrong with my code, but yet there is...

My MainForm opens up the AddTicketForm, to create and add an entry, prior to the closing of the AddTicketForm, it is supposed to call the function on the MainForm that will refresh the DataGrid, so that it will show the newly added entry... But for some reason it will not allow me on the AddTicketForm to create an object reference of the MainForm so that I may call the function... I keep getting the error "No overload for method 'MainForm' takes '0' arguments"... Here's my code...

namespace MPCS
{
	public partial class MainForm : Form
	{
		public void loadTicketsDataGrid(int CID)
		{
			ticketsDataGridView.DataSource = TicketsQueries.GetTicketsByCustomerID(CID);

			ticketsDataGridView.Columns[0].Name = "TicketID";
			ticketsDataGridView.Columns[0].DataPropertyName = "TicketID";
			ticketsDataGridView.Columns[0].Width = 5;
			ticketsDataGridView.Columns[0].HeaderText = "";
			ticketsDataGridView.Columns[0].Visible = false;

			etc. etc. etc.
		}
		private void addTicketToolStripMenuItem_Click(object sender, EventArgs e)
		{
			AddTicketForm AddTicketForm = new AddTicketForm(this);
			AddTicketForm.ShowDialog();
		}
	}
}


namespace MPCS
{
	public partial class AddTicketForm : Form
	{
		private int CID = 0;

		public AddTicketForm(MainForm Form1)
		{
			InitializeComponent();
			CID = Form1.CID;
		}
		private void newTicketButton_Click(object sender, EventArgs e)
		{
			code code code
			if (errorTracker == 0)
			{
				decimal ticketProfit = (ticketTotal * TherapistPercentage) / 100;
				TicketsQueries.InsertTicket(ticketDateTimePicker.Value, ticketDescriptionTextBox.Text, TID, CID, billedTime, billedRate, ticketTotal, ticketPaidComboBox.Text, ticketProfit);
				MainForm mForm = new MainForm();
				mForm.loadTicketsDataGrid(CID);
				this.Close();
			}
		}
	}
}


The error is on "MainForm mForm = new MainForm();"

Is This A Good Question/Topic? 1

Replies To: No overload for method 'MainForm' takes '0' arguments

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6036
  • View blog
  • Posts: 23,422
  • Joined: 23-August 08

Re: No overload for method 'MainForm' takes '0' arguments

Posted 20 October 2008 - 09:27 AM

You don't show the constructor for the MainForm class, but it appears that your MainForm constructor requires an argument you're not providing.
Was This Post Helpful? 0
  • +
  • -

#3 webwired  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 33
  • View blog
  • Posts: 339
  • Joined: 26-August 07

Re: No overload for method 'MainForm' takes '0' arguments

Posted 20 October 2008 - 02:57 PM

I don't understand, I can't imagine any arguments that the MainForm would require...
Was This Post Helpful? 0
  • +
  • -

#4 wingot  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 52
  • Joined: 13-October 08

Re: No overload for method 'MainForm' takes '0' arguments

Posted 20 October 2008 - 04:37 PM

Hey webwired,

Your mainform is inheriting from Form but does not specify its own constructor. From my understanding it should just pick up Form's constructor, but the following code snippet in MainForm should make this work explicitly:

public void MainForm() : base()
{
}


This post has been edited by wingot: 20 October 2008 - 04:37 PM

Was This Post Helpful? 0
  • +
  • -

#5 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,957
  • Joined: 21-March 08

Re: No overload for method 'MainForm' takes '0' arguments

Posted 21 October 2008 - 06:43 AM

View Postwebwired, on 20 Oct, 2008 - 05:57 PM, said:

I don't understand, I can't imagine any arguments that the MainForm would require...


the code that you posted for the "MainForm" class....is that ALL of the code in the class? or did you leave some out thinking it wasn't necessary?
Was This Post Helpful? 0
  • +
  • -

#6 webwired  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 33
  • View blog
  • Posts: 339
  • Joined: 26-August 07

Re: No overload for method 'MainForm' takes '0' arguments

Posted 21 October 2008 - 08:13 AM

View Postwingot, on 20 Oct, 2008 - 04:37 PM, said:

Hey webwired,

Your mainform is inheriting from Form but does not specify its own constructor. From my understanding it should just pick up Form's constructor, but the following code snippet in MainForm should make this work explicitly:

public void MainForm() : base()
{
}



I tried that, but as soon as I entered in that code, intellisense went nuts, underlining nearly everything in the form...

Quote

the code that you posted for the "MainForm" class....is that ALL of the code in the class? or did you leave some out thinking it wasn't necessary?


Yes, you are correct, I only posted what I thought was relevant,... here is the entire MainForm, in case I left out something important...

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

namespace MPCS
{
	public partial class MainForm : Form
	{
		public int TID = 0;
		string therapistName = "";
		public int CID = 0;

		public MainForm(LogInForm LogInForm)
		{
			InitializeComponent();
			TID = LogInForm.TID;
			therapistName = LogInForm.therapistName;
		}

		private void MainForm_Load(object sender, EventArgs e)
		{
			customersDataGridView.CellContentDoubleClick += new DataGridViewCellEventHandler(customersDataGridView_CellContentDoubleClick);
			customersDataGridView.CellContentClick += new DataGridViewCellEventHandler(customersDataGridView_CellContentClick);
			if (therapistName == "admin")
			{
				addTherapistToolStripMenuItem.Enabled = true;
			}
			else
			{
				addCustomerToolStripMenuItem.Enabled = true;
			}
			if (therapistName == "admin")
			{
				customersDataGridView.DataSource = CustomersQueries.GetAllCustomers();
			}
			else
			{
				customersDataGridView.DataSource = CustomersQueries.GetCustomersByTherapistID(TID);
			}
			customersDataGridView.Columns[0].Name = "CustomerID";
			customersDataGridView.Columns[0].DataPropertyName = "CustomerID";
			customersDataGridView.Columns[0].Width = 5;
			customersDataGridView.Columns[0].HeaderText = "";
			customersDataGridView.Columns[0].Visible = false;

			customersDataGridView.Columns[1].Name = "CustomerFirstName";
			customersDataGridView.Columns[1].DataPropertyName = "CustomerFirstName";
			customersDataGridView.Columns[1].Width = 100;
			customersDataGridView.Columns[1].HeaderText = "First Name";

			customersDataGridView.Columns[2].Name = "CustomerLastName";
			customersDataGridView.Columns[2].DataPropertyName = "CustomerLastName";
			customersDataGridView.Columns[2].Width = 100;
			customersDataGridView.Columns[2].HeaderText = "Last Name";

			customersDataGridView.Columns[3].Name = "CustomerPhone";
			customersDataGridView.Columns[3].DataPropertyName = "CustomerPhone";
			customersDataGridView.Columns[3].Width = 85;
			customersDataGridView.Columns[3].HeaderText = "Phone";

			customersDataGridView.Columns[4].Name = "CustomerMobile";
			customersDataGridView.Columns[4].DataPropertyName = "CustomerMobile";
			customersDataGridView.Columns[4].Width = 85;
			customersDataGridView.Columns[4].HeaderText = "Mobile";

			customersDataGridView.Columns[5].Name = "CustomerEmail";
			customersDataGridView.Columns[5].DataPropertyName = "CustomerEmail";
			customersDataGridView.Columns[5].Width = 150;
			customersDataGridView.Columns[5].HeaderText = "Email";

			customersDataGridView.Columns[6].Name = "CustomerAddress";
			customersDataGridView.Columns[6].DataPropertyName = "CustomerAddress";
			customersDataGridView.Columns[6].Width = 100;
			customersDataGridView.Columns[6].HeaderText = "Address";

			customersDataGridView.Columns[7].Name = "CustomerCity";
			customersDataGridView.Columns[7].DataPropertyName = "CustomerCity";
			customersDataGridView.Columns[7].Width = 100;
			customersDataGridView.Columns[7].HeaderText = "City";

			customersDataGridView.Columns[8].Name = "CustomerState";
			customersDataGridView.Columns[8].DataPropertyName = "CustomerState";
			customersDataGridView.Columns[8].Width = 100;
			customersDataGridView.Columns[8].HeaderText = "State";

			customersDataGridView.Columns[9].Name = "CustomerZip";
			customersDataGridView.Columns[9].DataPropertyName = "CustomerZip";
			customersDataGridView.Columns[9].Width = 100;
			customersDataGridView.Columns[9].HeaderText = "Zip code";

			customersDataGridView.Columns[10].Name = "TherapistID";
			customersDataGridView.Columns[10].DataPropertyName = "TherapistID";
			customersDataGridView.Columns[10].Width = 5;
			customersDataGridView.Columns[10].HeaderText = "";
			customersDataGridView.Columns[10].Visible = false;
		}

		private void customersLastNameToolStripButton_Click(object sender, EventArgs e)
		{
			if (therapistName == "admin")
			{
				customersDataGridView.DataSource = CustomersQueries.GetCustomersByLastName(customersLastNameToolStripButton.Text);
			}
			else
			{
				customersDataGridView.DataSource = CustomersQueries.GetCustomersByLastName_TherapistID(TID, customersLastNameToolStripButton.Text);
			}
			customersDataGridView.Columns[0].Name = "CustomerID";
			customersDataGridView.Columns[0].DataPropertyName = "CustomerID";
			customersDataGridView.Columns[0].Width = 5;
			customersDataGridView.Columns[0].HeaderText = "";
			customersDataGridView.Columns[0].Visible = false;

			customersDataGridView.Columns[1].Name = "CustomerFirstName";
			customersDataGridView.Columns[1].DataPropertyName = "CustomerFirstName";
			customersDataGridView.Columns[1].Width = 100;
			customersDataGridView.Columns[1].HeaderText = "First Name";

			customersDataGridView.Columns[2].Name = "CustomerLastName";
			customersDataGridView.Columns[2].DataPropertyName = "CustomerLastName";
			customersDataGridView.Columns[2].Width = 100;
			customersDataGridView.Columns[2].HeaderText = "Last Name";

			customersDataGridView.Columns[3].Name = "CustomerPhone";
			customersDataGridView.Columns[3].DataPropertyName = "CustomerPhone";
			customersDataGridView.Columns[3].Width = 85;
			customersDataGridView.Columns[3].HeaderText = "Phone";

			customersDataGridView.Columns[4].Name = "CustomerMobile";
			customersDataGridView.Columns[4].DataPropertyName = "CustomerMobile";
			customersDataGridView.Columns[4].Width = 85;
			customersDataGridView.Columns[4].HeaderText = "Mobile";

			customersDataGridView.Columns[5].Name = "CustomerEmail";
			customersDataGridView.Columns[5].DataPropertyName = "CustomerEmail";
			customersDataGridView.Columns[5].Width = 150;
			customersDataGridView.Columns[5].HeaderText = "Email";

			customersDataGridView.Columns[6].Name = "CustomerAddress";
			customersDataGridView.Columns[6].DataPropertyName = "CustomerAddress";
			customersDataGridView.Columns[6].Width = 100;
			customersDataGridView.Columns[6].HeaderText = "Address";

			customersDataGridView.Columns[7].Name = "CustomerCity";
			customersDataGridView.Columns[7].DataPropertyName = "CustomerCity";
			customersDataGridView.Columns[7].Width = 100;
			customersDataGridView.Columns[7].HeaderText = "City";

			customersDataGridView.Columns[8].Name = "CustomerState";
			customersDataGridView.Columns[8].DataPropertyName = "CustomerState";
			customersDataGridView.Columns[8].Width = 100;
			customersDataGridView.Columns[8].HeaderText = "State";

			customersDataGridView.Columns[9].Name = "CustomerZip";
			customersDataGridView.Columns[9].DataPropertyName = "CustomerZip";
			customersDataGridView.Columns[9].Width = 100;
			customersDataGridView.Columns[9].HeaderText = "Zip code";

			customersDataGridView.Columns[10].Name = "TherapistID";
			customersDataGridView.Columns[10].DataPropertyName = "TherapistID";
			customersDataGridView.Columns[10].Width = 5;
			customersDataGridView.Columns[10].HeaderText = "";
			customersDataGridView.Columns[10].Visible = false;
		}

		public void loadTicketsDataGrid(int CID)
		{
			ticketsDataGridView.DataSource = TicketsQueries.GetTicketsByCustomerID(CID);

			ticketsDataGridView.Columns[0].Name = "TicketID";
			ticketsDataGridView.Columns[0].DataPropertyName = "TicketID";
			ticketsDataGridView.Columns[0].Width = 5;
			ticketsDataGridView.Columns[0].HeaderText = "";
			ticketsDataGridView.Columns[0].Visible = false;

			ticketsDataGridView.Columns[1].Name = "TicketDate";
			ticketsDataGridView.Columns[1].DataPropertyName = "TicketDate";
			ticketsDataGridView.Columns[1].Width = 110;
			ticketsDataGridView.Columns[1].HeaderText = "Date";

			ticketsDataGridView.Columns[2].Name = "TicketDescription";
			ticketsDataGridView.Columns[2].DataPropertyName = "TicketDescription";
			ticketsDataGridView.Columns[2].Width = 200;
			ticketsDataGridView.Columns[2].HeaderText = "Description";

			ticketsDataGridView.Columns[3].Name = "TherapistID";
			ticketsDataGridView.Columns[3].DataPropertyName = "TherapistID";
			ticketsDataGridView.Columns[3].Width = 5;
			ticketsDataGridView.Columns[3].HeaderText = "";
			ticketsDataGridView.Columns[3].Visible = false;

			ticketsDataGridView.Columns[4].Name = "CustomerID";
			ticketsDataGridView.Columns[4].DataPropertyName = "CustomerID";
			ticketsDataGridView.Columns[4].Width = 5;
			ticketsDataGridView.Columns[4].HeaderText = "";
			ticketsDataGridView.Columns[4].Visible = false;

			ticketsDataGridView.Columns[5].Name = "TicketBillableTime";
			ticketsDataGridView.Columns[5].DataPropertyName = "TicketBillableTime";
			ticketsDataGridView.Columns[5].Width = 75;
			ticketsDataGridView.Columns[5].HeaderText = "Time";

			ticketsDataGridView.Columns[6].Name = "TicketBillableRate";
			ticketsDataGridView.Columns[6].DataPropertyName = "TicketBillableRate";
			ticketsDataGridView.Columns[6].Width = 75;
			ticketsDataGridView.Columns[6].HeaderText = "Rate";
			this.ticketsDataGridView.Columns[6].DefaultCellStyle.Format = "c";

			ticketsDataGridView.Columns[7].Name = "TicketTotal";
			ticketsDataGridView.Columns[7].DataPropertyName = "TicketTotal";
			ticketsDataGridView.Columns[7].Width = 75;
			ticketsDataGridView.Columns[7].HeaderText = "Total";
			this.ticketsDataGridView.Columns[7].DefaultCellStyle.Format = "c";

			ticketsDataGridView.Columns[8].Name = "TicketPaid";
			ticketsDataGridView.Columns[8].DataPropertyName = "TicketPaid";
			ticketsDataGridView.Columns[8].Width = 75;
			ticketsDataGridView.Columns[8].HeaderText = "Paid";

			ticketsDataGridView.Columns[9].Name = "TicketProfit";
			ticketsDataGridView.Columns[9].DataPropertyName = "TicketProfit";
			ticketsDataGridView.Columns[9].Width = 5;
			ticketsDataGridView.Columns[9].HeaderText = "";
			ticketsDataGridView.Columns[9].Visible = false;
		}

		private void customersDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
		{
			string tempVar = customersDataGridView.Rows[e.RowIndex].Cells[0].FormattedValue.ToString();
			CID = int.Parse(tempVar);
			if (therapistName != "admin")
			{
				addTicketToolStripButton.Visible = true;
				addTicketToolStripMenuItem.Enabled = true;
				loadTicketsDataGrid(CID);
			}
			editCustomerToolStripMenuItem.Enabled = true;
		}

		private void customersDataGridView_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
		{
			if (therapistName != "admin")
			{
				AddTicketForm AddTicketForm = new AddTicketForm(this);
				AddTicketForm.ShowDialog();
			}
		}

		private void addTicketToolStripButton_Click(object sender, EventArgs e)
		{
			AddTicketForm AddTicketForm = new AddTicketForm(this);
			AddTicketForm.ShowDialog();
		}

		private void addTicketToolStripMenuItem_Click(object sender, EventArgs e)
		{
			AddTicketForm AddTicketForm = new AddTicketForm(this);
			AddTicketForm.ShowDialog();
		}

		private void editCustomerToolStripMenuItem_Click(object sender, EventArgs e)
		{

		}

		private void addCustomerToolStripMenuItem_Click(object sender, EventArgs e)
		{

		}

		private void editTicketToolStripMenuItem_Click(object sender, EventArgs e)
		{

		}

		private void addTherapistToolStripMenuItem_Click(object sender, EventArgs e)
		{

		}

		private void editTherapistToolStripMenuItem_Click(object sender, EventArgs e)
		{

		}
	}
}


Was This Post Helpful? 0
  • +
  • -

#7 wingot  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 52
  • Joined: 13-October 08

Re: No overload for method 'MainForm' takes '0' arguments

Posted 21 October 2008 - 08:45 AM

View Postwebwired, on 21 Oct, 2008 - 08:13 AM, said:

Hey webwired,

Your mainform is inheriting from Form but does not specify its own constructor. From my understanding it should just pick up Form's constructor, but the following code snippet in MainForm should make this work explicitly:

public void MainForm() : base()
{
}



I tried that, but as soon as I entered in that code, intellisense went nuts, underlining nearly everything in the form...


Err, sorry, remove the void and it should work :).
Was This Post Helpful? 0
  • +
  • -

#8 webwired  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 33
  • View blog
  • Posts: 339
  • Joined: 26-August 07

Re: No overload for method 'MainForm' takes '0' arguments

Posted 21 October 2008 - 09:02 AM

View Postwingot, on 21 Oct, 2008 - 08:45 AM, said:

View Postwebwired, on 21 Oct, 2008 - 08:13 AM, said:

Hey webwired,

Your mainform is inheriting from Form but does not specify its own constructor. From my understanding it should just pick up Form's constructor, but the following code snippet in MainForm should make this work explicitly:

public void MainForm() : base()
{
}



I tried that, but as soon as I entered in that code, intellisense went nuts, underlining nearly everything in the form...


Err, sorry, remove the void and it should work :).


Thank you wingot for your assistance, but it did the same thing...
Was This Post Helpful? 0
  • +
  • -

#9 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1638
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: No overload for method 'MainForm' takes '0' arguments

Posted 21 October 2008 - 09:06 AM

Here's your problem

public MainForm(LogInForm LogInForm)
{
       InitializeComponent();
       TID = LogInForm.TID;
       therapistName = LogInForm.therapistName;
}



If you notice, in that signature it's expecting something of LogInForm and you seem to be passing it nothing. Also, the type and name of your parameter should never be the same
Was This Post Helpful? 0
  • +
  • -

#10 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: No overload for method 'MainForm' takes '0' arguments

Posted 21 October 2008 - 09:36 AM

If you explicitly define a constructor then you also have to explicitly define the default constructor for the class, as well.

The only time the default constructor exists is if you don't specify any constructors for your class.

So you are getting the error message because you do not have a default constructor that doesn't take any parameters.
Was This Post Helpful? 0
  • +
  • -

#11 webwired  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 33
  • View blog
  • Posts: 339
  • Joined: 26-August 07

Re: No overload for method 'MainForm' takes '0' arguments

Posted 21 October 2008 - 09:46 AM

View PostPsychoCoder, on 21 Oct, 2008 - 09:06 AM, said:

Here's your problem

public MainForm(LogInForm LogInForm)
{
       InitializeComponent();
       TID = LogInForm.TID;
       therapistName = LogInForm.therapistName;
}



If you notice, in that signature it's expecting something of LogInForm and you seem to be passing it nothing. Also, the type and name of your parameter should never be the same


From the LogInForm, I'm passing the TID and also the therapistName...
Was This Post Helpful? 0
  • +
  • -

#12 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1638
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: No overload for method 'MainForm' takes '0' arguments

Posted 21 October 2008 - 09:49 AM

What is TID? You constructor is looking for the type LoginInForm which, from what I've read of your code, is the actual form.
Was This Post Helpful? 0
  • +
  • -

#13 webwired  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 33
  • View blog
  • Posts: 339
  • Joined: 26-August 07

Re: No overload for method 'MainForm' takes '0' arguments

Posted 21 October 2008 - 09:49 AM

View Postjayman9, on 21 Oct, 2008 - 09:36 AM, said:

If you explicitly define a constructor then you also have to explicitly define the default constructor for the class, as well.

The only time the default constructor exists is if you don't specify any constructors for your class.

So you are getting the error message because you do not have a default constructor that doesn't take any parameters.


Would you happen to have an example of how that works, sorry, this is quite a bit more different than VB .NET than I had expected, and learning C# has proven a bit more complex than I had originally anticipated...
Was This Post Helpful? 0
  • +
  • -

#14 webwired  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 33
  • View blog
  • Posts: 339
  • Joined: 26-August 07

Re: No overload for method 'MainForm' takes '0' arguments

Posted 21 October 2008 - 10:02 AM

View PostPsychoCoder, on 21 Oct, 2008 - 09:49 AM, said:

What is TID?


In the LogInForm, a therapist enters a therapistName and a therapistPassword, it then queries the database and returns a TID, which is actually just short for therapistID... If a therapistID or TID is returned greater than zero, it opens up the MainForm for them... passing the TID and therapistName...

View PostPsychoCoder, on 21 Oct, 2008 - 09:49 AM, said:

You constructor is looking for the type LoginInForm which, from what I've read of your code, is the actual form.


From what I researched and found, passing the Form was the easiest way of passing any of the variables within it...

Should I be using a different way?
Was This Post Helpful? 0
  • +
  • -

#15 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,957
  • Joined: 21-March 08

Re: No overload for method 'MainForm' takes '0' arguments

Posted 21 October 2008 - 10:08 AM

View Postwebwired, on 21 Oct, 2008 - 01:02 PM, said:

View PostPsychoCoder, on 21 Oct, 2008 - 09:49 AM, said:

What is TID?


In the LogInForm, a therapist enters a therapistName and a therapistPassword, it then queries the database and returns a TID, which is actually just short for therapistID... If a therapistID or TID is returned greater than zero, it opens up the MainForm for them... passing the TID and therapistName...

View PostPsychoCoder, on 21 Oct, 2008 - 09:49 AM, said:

You constructor is looking for the type LoginInForm which, from what I've read of your code, is the actual form.


From what I researched and found, passing the Form was the easiest way of passing any of the variables within it...

Should I be using a different way?


your contructor should look like this...

public MainForm(LogInForm logInForm)
{
       InitializeComponent();
       TID = logInForm.TID;
       therapistName = logInForm.therapistName;
}



notice how "LogInForm" and "logInForm" are different? You can't give a variable name the same name as a class. "LogInName" is the data type and "logInName" is the variable.


EDITED: on second thought, instead of passing the entire form object, just pass what you need.

public MainForm(int tid, string name)
{
       InitializeComponent();
       TID = tid;
       therapistName = name;
}



and then your line of code that is currently give you the error should be this..

MainForm mForm = new MainForm(TID, therapistName);


This post has been edited by eclipsed4utoo: 21 October 2008 - 10:13 AM

Was This Post Helpful? 1
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2