I'm trying to make it so that my form does not appear blank. It was working before, It wouldn't let me save my file at one point so I renamed it to form3temp and now the form shows up when I run it, but not when I look at it in design view. Form 5 also does the same thing. The rest of my 7 forms are fine.
How it appears inside design
https://i.gyazo.com/06994988ff2f307d5042c0bafec1c43e.png
How it appears when I run the application
https://gyazo.com/97c1838e55f5f595b09211f2ee742c9f
namespace LawnCarePrototype
{
public partial class Form31 : Form
{
public static decimal yardCost = 0.0M;
decimal yardSizeMultiplier = 0.0M;
public Form31()
{
InitializeComponent();
}
private void Form3_Load(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
yardSizeMultiplier = 0.0M;
yardCost = 0.0M;
if (radioButton1.Checked)
{
yardSizeMultiplier = 0.8M;
}
if (radioButton2.Checked)
{
yardSizeMultiplier = 1.0M;
}
if (radioButton3.Checked)
{
yardSizeMultiplier = 1.2M;
}
if (checkBox1.Checked)
{
yardCost =+ 15.00M * yardSizeMultiplier;
//2 EDGE
Global.edgeExp = 15.00M * yardSizeMultiplier;
}
if (checkBox2.Checked)
{
yardCost =+30.00M * yardSizeMultiplier;
Global.bushExp = 30.00M * yardSizeMultiplier;
//3 BUSH
}
if (checkBox3.Checked)
{
yardCost =+ 25.00M * yardSizeMultiplier;
Global.leafExp = 25.00M * yardSizeMultiplier;
//4 LEAF
}
if (checkBox4.Checked)
{
yardCost =+ 35.00M * yardSizeMultiplier;
//1 LAWN
Global.MowExp = 35.00M * yardSizeMultiplier;
}
if (yardCost == 0.00M)
{
MessageBox.Show("Please Input Your Selection");
}
else
{
Form4 form4obj = new Form4();
form4obj.Show();
this.Close();
}
Global.subTotal = yardCost;
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
Form2 form2obj = new Form2();
form2obj.Show();
this.Close();
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
}
private void checkBox4_CheckedChanged(object sender, EventArgs e)
{
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
private void groupBox1_Enter(object sender, EventArgs e)
{
}
}
}
I expect the form design to appear because I don't see any errors.
Not sure what could be causing this in my code.
Side Note: Sorry for the poor code format!
Related
Basically I would like to stop my system from allowing the user to be able to create multiple bookings under the same time slot for a booking if that makes sense. My system basically allows a user to make a booking for a walk, and ideally each walk should only be able to be booked from Monday to Sunday during working hours, but a slot should be 1.5 hours each but at the moment, there is no slots, just the date time pickers for the time and date of the booking and for multiple bookings the user can just pick the same time so i do want to get that fixed.
Hopefully this helps- I have attached my code for my "add booking" form so hopefully thats of some use.
public partial class AddBooking : Form
{
private int count;
private Boolean IsEmpty = false;
private static string _connectionstring = ConfigurationManager.ConnectionStrings["DoggieConnectionString"].ConnectionString;
public AddBooking()
{
InitializeComponent();
CenterToScreen();
GenerateBookingNumber();
IDDisplay.Text = "" + count;
dateTimePicker2.Format = DateTimePickerFormat.Custom;
dateTimePicker2.CustomFormat = "HH:mm tt";
dateTimePicker2.ShowUpDown = true;
DateTime now = DateTime.Now;
}
private void AddBooking_Load(object sender, EventArgs e)
{
}
private int GenerateBookingNumber()
{
string smt = "SELECT COUNT(*) FROM dbo.Booking";
count = 0;
using (SqlConnection connection = new SqlConnection(_connectionstring))
{
using (SqlCommand cmdCount = new SqlCommand(smt, connection))
{
connection.Open();
count = (int)Convert.ToInt32(cmdCount.ExecuteScalar());
}
}
count = count + 4;
return count;
}
private void PresenceCheck()
{
if (string.IsNullOrEmpty(WalkLocationtxt.Text) || string.IsNullOrEmpty(StaffIDtxt.Text))
{
IsEmpty = true;
}
else
{
IsEmpty = false;
}
}
private void SubmitInfobtn_Click(object sender, EventArgs e)
{
// MessageBox.Show("welcome " + dateTimePicker1.Value.ToShortDateString());
// MessageBox.Show("Goodddd" + dateTimePicker2.Value.ToShortTimeString());
PresenceCheck();
if (IsEmpty == false)
{
int rowsareaffected = ClassDatabase.AddBookingDetails(Convert.ToInt32(IDDisplay.Text), dateTimePicker1.Value.ToShortDateString(), dateTimePicker2.Value.ToShortTimeString(), Convert.ToInt32(StaffIDtxt.Text), WalkLocationtxt.Text);
if (rowsareaffected > 0)
{
MessageBox.Show("New Booking Added Sucessfully", "Sucess!", MessageBoxButtons.OK, MessageBoxIcon.Information);
StaffIDtxt.Clear();
WalkLocationtxt.Clear();
GenerateBookingNumber();
IDDisplay.Text = "" + count;
}
else
{
MessageBox.Show("An Error Occurred", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void dateTimePicker2_ValueChanged(object sender, EventArgs e)
{
}
private void mENUToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void returnToMenuToolStripMenuItem_Click(object sender, EventArgs e)
{
new MenuScreen().Show();
this.Close();
}
private void logOutToolStripMenuItem_Click(object sender, EventArgs e)
{
new LoginScreen().Show();
this.Close();
}
private void exitSystemToolStripMenuItem_Click(object sender, EventArgs e)
{
DialogResult Result = MessageBox.Show("Are you sure you want to Exit the JD Dog Care Program?", "Are You Sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Hand);
if (Result == DialogResult.Yes)
{
Application.Exit();
}
else
{
}
}
private void addClientToolStripMenuItem_Click(object sender, EventArgs e)
{
new AddClient().Show();
this.Close();
}
private void manageClientsToolStripMenuItem_Click(object sender, EventArgs e)
{
new ViewClient().Show();
this.Close();
}
private void addDogsToolStripMenuItem_Click(object sender, EventArgs e)
{
new AddDog().Show();
this.Close();
}
private void manageDogsToolStripMenuItem_Click(object sender, EventArgs e)
{
new ViewDog().Show();
this.Close();
}
private void addStaffToolStripMenuItem_Click(object sender, EventArgs e)
{
new AddStaff().Show();
this.Close();
}
private void manageStaffToolStripMenuItem_Click(object sender, EventArgs e)
{
new ViewStaff().Show();
this.Close();
}
private void addBookingToolStripMenuItem_Click(object sender, EventArgs e)
{
new AddBooking().Show();
this.Close();
}
private void manageBookingToolStripMenuItem_Click(object sender, EventArgs e)
{
new ViewBooking().Show();
this.Close();
}
private void addDogToBookingToolStripMenuItem_Click(object sender, EventArgs e)
{
new DogToWalk().Show();
this.Close();
}
}
}
I need to calculate the Lb1SumF plus Lb2SumF equal Lb3SumF.
I ran it, and somehow the label3 does not display the expected result.
Here is a screenshot from result.
Here is my code.
private void Form1_Load(object sender, EventArgs e)
{
TX1.TabIndex=0;
}
private void TX1_TextChanged(object sender, EventArgs e)
{
try
{
int sumF;
sumF = Convert.ToInt32(Lb1PriceF.Text) * Convert.ToInt32(TX1.Text);
Lb1SumF.Text = Convert.ToString(sumF); //Label1 sum
}
catch
{
Lb1SumF.Text = "0";
}
}
private void TX2_TextChanged(object sender, EventArgs e)
{
try
{
int sumF;
sumF = Convert.ToInt32(Lb2PriceF.Text) * Convert.ToInt32(TX2.Text);
Lb2SumF.Text = Convert.ToString(sumF); //Label2 sum
}
catch
{
Lb2SumF.Text = "0";
}
}
private void Lb3_TextChanged(object sender, EventArgs e)
{
int i = Convert.ToInt32(Lb1SumF.Text);
int j = Convert.ToInt32(Lb2SumF.Text);
Lb3.Text = Convert.ToString(i+j); // Label3 sum
}
Lb3_TextChanged might never be invoked as you are not changing the text of the label. I would suggest to change it to a private method and not an event handler. Here is what the code could be like:
private void TX1_TextChanged(object sender, EventArgs e)
{
try
{
int sumF;
sumF = Convert.ToInt32(Lb1PriceF.Text) * Convert.ToInt32(TX1.Text);
Lb1SumF.Text = Convert.ToString(sumF); //Label1 sum
// Call to update sum
UpdateSum();
}
catch
{
Lb1SumF.Text = "0";
}
}
private void TX2_TextChanged(object sender, EventArgs e)
{
try
{
int sumF;
sumF = Convert.ToInt32(Lb2PriceF.Text) * Convert.ToInt32(TX2.Text);
Lb2SumF.Text = Convert.ToString(sumF); //Label2 sum
// Call to update sum
UpdateSum();
}
catch
{
Lb2SumF.Text = "0";
}
}
// private void Lb3_TextChanged(object sender, EventArgs e)
private void UpdateSum()
{
int sum = 0;
if(!string.IsNullOrEmpty(Lb1SumF.Text) && !string.IsNullOrEmpty(Lb2SumF.Text))
{
sum = Convert.ToInt32(Lb1SumF.Text) + Convert.ToInt32(Lb2SumF.Text);
}
Lb3.Text = Convert.ToString(sum);
}
Replace you code with this it will work, you are using * operator where you have to use + operator, I have commented that lines in your code and replaced it for better understanding.
Happy Coding
namespace WindowsFormsApp8
{
public partial class Form1 : Form
{
private void Lb1SumF_Click(object sender, EventArgs e)
{
}
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
TX1.TabIndex=0;
}
private void label4_Click(object sender, EventArgs e)
{
}
private void TX1_TextChanged(object sender, EventArgs e)
{
try
{
int sumF;
//sumF = Convert.ToInt32(Lb1PriceF.Text) * Convert.ToInt32(TX1.Text); // You were doing wrong here , you were multiplying these values
sumF = Convert.ToInt32(Lb1PriceF.Text) + Convert.ToInt32(TX1.Text);
Lb1SumF.Text = Convert.ToString(sumF); //Label1 sum
}
catch
{
Lb1SumF.Text = "0";
}
}
private void TX2_TextChanged(object sender, EventArgs e)
{
try
{
int sumF;
//sumF = Convert.ToInt32(Lb2PriceF.Text) * Convert.ToInt32(TX2.Text); //you are doing it wrong here , you are multiplying
sumF = Convert.ToInt32(Lb2PriceF.Text) + Convert.ToInt32(TX2.Text);
Lb2SumF.Text = Convert.ToString(sumF); //Label2 sum
}
catch
{
Lb2SumF.Text = "0";
}
}
private void Lb3_TextChanged(object sender, EventArgs e)
{
int i = Convert.ToInt32(Lb1SumF.Text);
int j = Convert.ToInt32(Lb2SumF.Text);
Lb3.Text = Convert.ToString(i+j); // Label3 sum
}
private void Lb3SumF_Click(object sender, EventArgs e)
{
}
}
}
can someone help me on my problem I'm making an ordering system for our thesis and I don't know what to do next if 3 button is clicked
Things I want to happen:
user need to pick an item first then he/she will pick a quantity for the item(I have 10 buttons for quantity: 1,2,3,4,5,6,7,8,9,0)
so I add a button0 so the user need to pick item and then click button1 then button0 to have a quantity of 10 that will display in my listview
1-9 button is working now but my problem is what if the user wants the item for a quantity of 10 or more
so here I have my code for an item button1
private void button1_Click(object sender, EventArgs e)
{
ms = 1;
}
and the quantity button
private void button1_Click(object sender, EventArgs e)
{
if(ms == 1)
{
ListViewItem item = new ListViewItem(btnms1.Text);
item.SubItems.Add("1");
item.SubItems.Add("118");
listView1.Items.Add(item);
ms = 0;
}
}
private void button2_Click(object sender, EventArgs e)
{
//working
}
private void button3_Click(object sender, EventArgs e)
{
//working
}
private void button4_Click(object sender, EventArgs e)
{
//working
}
private void button5_Click(object sender, EventArgs e)
{
//working
}
private void button6_Click(object sender, EventArgs e)
{
//working
}
private void button7_Click(object sender, EventArgs e)
{
//working
}
private void button8_Click(object sender, EventArgs e)
{
//working
}
private void button9_Click(object sender, EventArgs e)
{
//working
}
here is the 0 button
private void button0_Click(object sender, EventArgs e)
{
// magic please
}
I'm not really sure what you want to achieve but it might be something like this.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text += "1";
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Text += "2";
}
private void button3_Click(object sender, EventArgs e)
{
textBox1.Text += "3";
}
private void button4_Click(object sender, EventArgs e)
{
textBox1.Text += "4";
}
private void button5_Click(object sender, EventArgs e)
{
textBox1.Text += "5";
}
private void button6_Click(object sender, EventArgs e)
{
textBox1.Text += "6";
}
private void button7_Click(object sender, EventArgs e)
{
textBox1.Text += "7";
}
private void button8_Click(object sender, EventArgs e)
{
textBox1.Text += "8";
}
private void button9_Click(object sender, EventArgs e)
{
textBox1.Text += "9";
}
private void button10_Click(object sender, EventArgs e)
{
textBox1.Text += "0";
}
private void button11_Click(object sender, EventArgs e)
{
int quantity = 0;
bool quantityParse = int.TryParse(textBox1.Text, out quantity);
string productName = "Product Name"; // Sample Name
double productPrice = 300; // Sample Price
if (quantityParse)
{
ListViewItem lvi = new ListViewItem(productName); // Name
lvi.SubItems.Add(quantity.ToString()); // Quantity
lvi.SubItems.Add(productPrice.ToString()); // Price
lvi.SubItems.Add((productPrice * quantity).ToString()); // Subtotal
listView1.Items.Add(lvi);
}
}
}
Firstly, please start picking more meaningful names for variables as they help with code comprehension, especially when your code gets too complex for you or when you are sharing with others.
Secondly, how you're doing this at the moment is not the most intuitive way to go about things, always aim for the least amount of code as possible.
What I would be doing is calling the same event handler for each of the quantity buttons, but parsing the text in the buttons as a integer and adding that to a total string.
Ie:
private string QuantityText = string.Empty;
private void QtyButton_Click(object sender, EventArgs e)
{
if (sender is Button)
{
Button theButton = (Button)sender;
string qtyText = theButton.Content.ToString();
QuantityText += qtyText;
}
}
Then call something like this method when you want to process the quantity string:
Private Void ProcessQuantity()
{
int qtyAmount = -1;
int.TryParse(QuantityText, out qtyAmount)
if (qtyAmount > -1)
{
//Do Processing here
}
else
{
throw new InvalidArgumentException("Quantity is invalid");
}
}
This question already has answers here:
What is a NullReferenceException, and how do I fix it?
(27 answers)
Closed 8 years ago.
Sorry for asking this question again but, I don't really know how to debug this.
The debugger is giving me nullreferenceexception in this line:
if (listBox1.SelectedItem.ToString() == "Chicken $15")
I figure that the reason why it is giving me nullreferenceexception is because listbox1 is null so I think I have to initialize it. But how? I dont know how to initialize a listbox.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace lab6
{
public partial class Form1 : Form
{
double total = 0;
int x = 0;
string ord = "";
public Form1()
{
InitializeComponent();
}
private void toolStripMenuItem1_Click(object sender, EventArgs e)
{
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
}
private void editToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void placeToolStripMenuItem_Click(object sender, EventArgs e)
{
checkBox1.Checked = false;
radioButton1.Checked = false;
radioButton2.Checked = false;
radioButton3.Checked = false;
radioButton4.Checked = false;
switch (checkBox1.Checked)
{
case true:
total += 1;
ord += "Water\n";
break;
}
if (comboBox1.Text == "Extra Meat")
{
total += 1;
ord += ord + "Extra Meat\n";
}
if (comboBox1.Text == "Extra Rice")
{
total += 1;
ord += "Extra Rice\n";
}
if (comboBox1.Text == "Extra Veggies")
{
total += 1;
ord += "Extra Veggies\n";
}
if (listBox1.SelectedItem.ToString() == "Chicken $15")
{
total += 15;
ord += " Chicken\n";
}
else { }
if (listBox1.SelectedItem.ToString() == "Pizza $8") //< my pathetic attempt to figure it out with intelisense
{
total += 8;
ord += "Pizza\n";
}
else
{
}
if (listBox1.SelectedItem.ToString() == "Spaghetti $12")//< my pathetic attempt to figure it out with intelisense
{
total += 12;
ord += " Spaghetti\n";
}
else { }
if (listBox1.SelectedItem.ToString() == "Fries $8")
{
total += 8;
ord += " Fries\n";
}
else { }
if (listBox1.SelectedItem.ToString() == "Burger $10")
{
total += 10;
ord += " Burger\n";
}
else { }
//radiobutton
if (radioButton1.Checked)
{
total+=5;
ord += "Pineapple Juice\n";
}
if (radioButton2.Checked)
{
total+=6;
ord += "Mango Juice\n";
}
if (radioButton3.Checked)
{
total+=7;
ord += "Apple Juice\n";
}
if (radioButton4.Checked)
{
total+=8;
ord += "Orange Juice\n";
}
MessageBox.Show("Order Done");
listBox1.SelectedItems.Clear();
}
private void clearToolStripMenuItem_Click(object sender, EventArgs e)
{
ord = "";
total = 0;
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
}
private void label3_Click(object sender, EventArgs e)
{
}
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
}
private void radioButton4_CheckedChanged(object sender, EventArgs e)
{
}
private void radioButton3_CheckedChanged(object sender, EventArgs e)
{
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void label4_Click(object sender, EventArgs e)
{
}
private void displayToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("Order: " + ord+"\nTotal: "+total);
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
It looks like you're assuming that listBox1.SelectedItem is never null, try doing somthing like
if (listBox1.SelectedItem != null)
{
// code here
}
I'm new to c#, and after looking through the other threads on this subject I'm still at a loss of how to fix the bug:C.
I'm trying to make a simple calculator and here is the code for that:
//Global Variables
string sign;
double val1;
double val2;
int trackkeypoint = 0;
public void Calculator()
{
InitializeComponent();
}
private void cmd0_Click(object sender, EventArgs e)
{
txtbox.Text = txtbox.Text + cmd0.Text;
}
private void cmd1_Click(object sender, EventArgs e)
{
txtbox.Text=txtbox.Text+cmd1.Text;
}
private void cmd2_Click(object sender, EventArgs e)
{
txtbox.Text=txtbox.Text+cmd2.Text;
}
private void cmd3_Click(object sender, EventArgs e)
{
txtbox.Text=txtbox.Text+cmd3.Text;
}
private void cmd4_Click(object sender, EventArgs e)
{
txtbox.Text=txtbox.Text+cmd4.Text;
}
private void cmd5_Click(object sender, EventArgs e)
{
txtbox.Text=txtbox.Text+cmd5.Text;
}
private void cmd6_Click(object sender, EventArgs e)
{
txtbox.Text=txtbox.Text+cmd6.Text;
}
private void cmd7_Click(object sender, EventArgs e)
{
txtbox.Text=txtbox.Text+cmd7.Text;
}
private void cmd8_Click(object sender, EventArgs e)
{
txtbox.Text=txtbox.Text+cmd8.Text;
}
private void cmd9_Click(object sender, EventArgs e)
{
txtbox.Text=txtbox.Text+cmd9.Text;
}
private void cmdequal_Click(object sender, EventArgs e)
{
val2 = double.Parse(txtbox.Text);
double result;
if(sign=="+")
{
result = val1 + val2;
txtbox.Text = result.ToString();
}
else if(sign=="-")
{
result = val1 - val2;
txtbox.Text = result.ToString();
}
else if(sign=="X")
{
result = val1 * val2;
txtbox.Text = result.ToString();
}
else if(sign=="/")
{
result = val1 / val2;
txtbox.Text = result.ToString();
}
}
private void cmdclear_Click(object sender, EventArgs e)
{
//Clears text
txtbox.Text = "";
val1 = 0;
val2 = 0;
sign = "";
}
private void cmdplus_Click(object sender, EventArgs e)
{
sign = "+";
val1 = double.Parse(txtbox.Text);
txtbox.Text = "";
}
private void cmdsubtract_Click(object sender, EventArgs e)
{
sign = "-";
val1 = double.Parse(txtbox.Text);
txtbox.Text = "";
}
private void cmdmultiply_Click(object sender, EventArgs e)
{
sign = "X";
val1 = double.Parse(txtbox.Text);
txtbox.Text = "";
}
private void cmddivide_Click(object sender, EventArgs e)
{
sign = "/";
val1 = double.Parse(txtbox.Text);
txtbox.Text = "";
}
private void cmdsqrt_Click(object sender, EventArgs e)
{
double v;
v = double.Parse(txtbox.Text);
txtbox.Text = Math.Sqrt(v).ToString();
}
private void cmdsquare_Click(object sender, EventArgs e)
{
double v;
v = double.Parse(txtbox.Text);
txtbox.Text = Math.Pow(v,2).ToString();
}
private void cmdsin_Click(object sender, EventArgs e)
{
double v;
v = double.Parse(txtbox.Text);
txtbox.Text = Math.Sin(v).ToString();
}
private void cmdcos_Click(object sender, EventArgs e)
{
double v;
v = double.Parse(txtbox.Text);
txtbox.Text = Math.Cos(v).ToString();
}
private void cmdtan_Click(object sender, EventArgs e)
{
double v;
v = double.Parse(txtbox.Text);
txtbox.Text = Math.Tan(v).ToString();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void txtbox_TextChanged(object sender, EventArgs e)
{
}
private void txtbox_KeyPress(object sender, KeyPressEventArgs e)
{
int keycode;
keycode = e.KeyChar;
//accept only number from key 0 to key 9, key back, and key dot
if (keycode >= 48 && keycode <= 57 || keycode==8 || keycode==32 || keycode==46)
{
//key dot allowed only one time
if (keycode == 46) ++trackkeypoint;
if (trackkeypoint > 1) { e.Handled = true; --trackkeypoint; }
}
else e.Handled = true;
}
private void txtbox_KeyDown(object sender, KeyEventArgs e)
{
}
}
}
and I get this error:
I tried changing that to CWindowsGUI and that didn't work, or removing the offending bits, or a host of other layman fixes. It also shows up in the designer window:
The namespace is the same on the CWindowsGUI.Designer.cs as the actual code thing
Looking at the class you provided I think you renamed your Form1 to Calculator
So try:
Application.Run(new Calculator());
Edit:
CWindowsGUI.cs
public partial class Calculator : Form
{
public Calculator() // Not public void Calculator()
{
InitializeComponent();
}
CWindowsGUI.Designer.cs
public partial class Calculator
First you need to fix some errors
private void Form1_Load(object sender, EventArgs e)
{
}
you do not have any form named as Form1 it seems that when you created application it created a form for you named as Form1 you just renamed it from solution explorer.
delete this load event.
public void Calculator()
{
InitializeComponent();
}
is it a constructor of your form CWindowsGUI
constructor name should be same as form name correct it.
Do You wants to run CWindowsGUI form first ???
Application.Run();
method defines that which form you wants to set as startup that's all
then try this :
Application.Run(new CWindowsGUI());
instead of
Application.Run(new Calculator());
my suggestion would be that delete this form(CWindowsGUI) and create a new form then code on that page also donot forget to change the form in
Application.Run(new CWindowsGUI());