Hi all. I am currently new to coding and i have this group project with my teammates but we are currently having difficulty with trying to show form 2 when the button in form 1 is pressed. It shows an error called CS0118('Form2' is a namespace but used like
a type). This is my code:
Your code looks like Windows Forms, not Web Forms. (https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.form.showdialog?view=net-5.0
) If you are working on a Windows Forms project (an application that runs on a Windows PC), you are in the wrong forum, but that link shows you how to do what you are trying to do. If you are working on a Web Forms project (a website), which is what this
forum is for, that code won't work. Please clarify which type of project you are working on.
Member
2 Points
5 Posts
Coping 1 project to another project.
Jan 27, 2021 09:30 AM|StarryNight_XD|LINK
Hi all. I am currently new to coding and i have this group project with my teammates but we are currently having difficulty with trying to show form 2 when the button in form 1 is pressed. It shows an error called CS0118('Form2' is a namespace but used like a type). This is my code:
private void button1_Click(object sender, EventArgs e)
{
Form2 thankyou;
thankyou = new Form2();
thankyou.showDialog();
}
Contributor
4933 Points
4205 Posts
Re: Coping 1 project to another project.
Jan 27, 2021 08:45 PM|DA924|LINK
private void button1_Click(object sender, EventArgs e)
{
var thankyou = new Form2();
thankyou.showDialog();
}
I can't see you project but try the above. If it works than find out what the usage of 'var' means in c#.
Member
2 Points
5 Posts
Re: Coping 1 project to another project.
Jan 28, 2021 12:17 AM|StarryNight_XD|LINK
It did not work. Like it still have the same error.
Contributor
5961 Points
2466 Posts
Re: Coping 1 project to another project.
Jan 28, 2021 03:31 AM|KathyW|LINK
Your code looks like Windows Forms, not Web Forms. (https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.form.showdialog?view=net-5.0 ) If you are working on a Windows Forms project (an application that runs on a Windows PC), you are in the wrong forum, but that link shows you how to do what you are trying to do. If you are working on a Web Forms project (a website), which is what this forum is for, that code won't work. Please clarify which type of project you are working on.
Member
2 Points
5 Posts
Re: Coping 1 project to another project.
Feb 15, 2021 07:59 AM|StarryNight_XD|LINK
ohhhh. sorry. Thank you!