8 Replies - 2093 Views - Last Post: 10 May 2012 - 05:57 AM Rate Topic: -----

#1 stonk  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 09-May 12

Copying Forms In C#

Posted 09 May 2012 - 09:54 AM

Hello Everyone

I am really new to programming in C# and my knowledge at the moment is pretty limited. I have been doing a project for college regarding a flight booking system in which I had to make two planes that can take bookings and give costs for this.
The only problem is I finished it all but foolishly forgot that I needed two flights, but instead I have just made one. I thought it would be easy enough to sort by just making a button that could switch between the two forms and then just copy the form exactly for the second flight. Sadly this was not the case and I keep getting this error message

Error	1	The item "obj\Debug\Scotia.Form1.resources" was specified more than once in the "Resources" parameter.  Duplicate items are not supported by the "Resources" parameter.	Scotia



As I said my knowledge is limited and I have no idea what this error is. Any help on how to duplicate the form succesfully would be much appreciated as everything else i have got running fine as well the code for the button I will be placing on the forms. Thanks In advance

Is This A Good Question/Topic? 0
  • +

Replies To: Copying Forms In C#

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5537
  • View blog
  • Posts: 11,868
  • Joined: 02-June 10

Re: Copying Forms In C#

Posted 09 May 2012 - 10:28 AM

I have no idea why you tried to copy an entire form, or how you fraked it up.

But if you already have a form that is your airplane layout, just make another instance of it.

SeatingChartForm one = new SeatingChartForm();
SeatingChartForm two = new SeatingChartForm();





Reminder to new folks anxious to help by just throwing out working code: This is homework and we don't provide completed code for homework. Rather we try to help the student comprehend the concept they are struggling with so they can write their own code. They are being graded on their skill not ours.

90% or more of the problems we see here are because rookies don't stop and plan nor block out their code into logical segments.
This article should help you see a way to block out your code by stubbing out the methods and logic, then filling in each method as you research it:
This is the 'Help me with my homework' article you wanted.
Suggestion:
Don't replace lines of code that don't work. Instead comment them out and put your new attemps below that. This will keep you from re-trying the same ideas over and over. Also, when you come back to us saying "I've tried this 100 different ways and still can't get it", we can actually see what you tried. So often a failed attempt is very very close and just needs a little nudge in the right direction. So if we can say "See what you did in attempt 3... blah blah" it helps a lot

// Try #1 - May 1, 0900hrs
//    code
//    code  
//    code
// Try #2 - May 2, 1700hrs   Okay, plan B.  What if I do it *this* way
//    code
//    code  
//    code
// Try #14 - May 3, 0500hrs after 5 cans of RedBull.  Maybe I should get some sleep. I can't think of anything else but this last idea
    code
    code  
    code


If you are using Visual Studio you can select a block of lines and hit control+k control+c (Kode Comment) to comment it out. control+k control+u (Kode Uncomment) to uncomment a selected block.

These articles may also apply:
What does this error mean?

Stages of asking for homework help on a forum.
I don't want you to write my code, just give me ideas on how to solve my problem. - Read this article
How NOT to go about your assignment
"It doesn't work" isn't good enough - How you can help us, to help you

What have to you tried to code so far? - Click the link

What part of what you have tried isn't working?
Are you getting error messages, or is it just not giving you the results you wanted?
(In other words, you at least have to make and show us your good faith effort to do your own coding. We are here to help you, not do it for you.)
Was This Post Helpful? 1
  • +
  • -

#3 stonk  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 09-May 12

Re: Copying Forms In C#

Posted 09 May 2012 - 12:24 PM

I was copying the form to try and keep my two forms uniformed instead of them looking slightly different.
I have fixed it now anyway so its all working as intended. However this was not me asking for code or for you to do my homework for me, I was asking a very general question regarding using Visual studio, very different from coming on here and asking for the code as I have seen many posters do.
Thanks for the help anyway
Was This Post Helpful? 0
  • +
  • -

#4 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5537
  • View blog
  • Posts: 11,868
  • Joined: 02-June 10

Re: Copying Forms In C#

Posted 09 May 2012 - 12:30 PM

Quote

I was copying the form to try and keep my two forms uniformed instead of them looking slightly different.



If you have designed the form, you don't have to design 20 copies of it to USE 20 copies of it. You just make a new instance of the one form.

If you make an AirplaneLayout form, you just make two instances of that form. You should not being making an AirplaneLayout1 and AirplaneLayout2 in your designer. Your project should not have two forms designed that look and act the same.
Was This Post Helpful? 2
  • +
  • -

#5 h4nnib4l  Icon User is offline

  • The Noid
  • member icon

Reputation: 1181
  • View blog
  • Posts: 1,677
  • Joined: 24-August 11

Re: Copying Forms In C#

Posted 09 May 2012 - 12:40 PM

tlhIn`toq's reply is not accusing you of anything; it's a massive compilation of resources that he has put together and offers to people whose questions fall under the umbrella of one of the points. you should make the effort to go through it all, there's a lot of good stuff in there.

the point of what he's telling you is that making a new form for each object is failing to understand object oriented programming. You make an object once, and instantiate it as many times as you need. For example, you don't need to make a class for each airplane you use. Model the airplane once:
class Airplane {
    *Attributes of an airplane*

    *Methods of an airplane*
}



and when you need a few airplanes, instantiate a few Airplane objects.

Airplane airplane1 = new Airplane();
Airplane airplane2 = new Airplane();



Each one has its own "copies" of the attributes and methods from the Airplane class. That is a fundamental part of object oriented programming. I really hope your class has covered this (don't see how it could miss it, but you never know anymore), and this is something you really need to study and practice until you get it, because that paradigm is what the C# language is built upon.

This post has been edited by h4nnib4l: 09 May 2012 - 12:41 PM

Was This Post Helpful? 2
  • +
  • -

#6 stonk  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 09-May 12

Re: Copying Forms In C#

Posted 09 May 2012 - 03:25 PM

Apologies If I came across snippy in my previous post. Was getting fed up trying to get the thing to work.

Sad fact is the comments the two of you have gave, I have learned more from them then I have at college. We have not been taught anything with Forms in C# only ever console applications which are not ideal for things like this.

Thanks again
Was This Post Helpful? 0
  • +
  • -

#7 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5537
  • View blog
  • Posts: 11,868
  • Joined: 02-June 10

Re: Copying Forms In C#

Posted 09 May 2012 - 03:32 PM

View Poststonk, on 09 May 2012 - 04:25 PM, said:

Sad fact is the comments the two of you have gave, I have learned more from them then I have at college.


The more sad fact is that we hear this a lot. I've said many time that college is in the business of taking 4 years of tuition off as many people as possible. It doesn't matter what the course is, it still takes the same amount of time - huh?

Doesn't it seem odd to you that you can walk into any bookstore (that hasn't filed bankruptcy) than buy a dozen books of "Learn C# in a month", but it takes your professor more than a year to teach the same amount of information?

Take the course for the piece of paper. But you can learn all of that 50 times faster on your own.

90% or more of the problems we see here are because rookies don't stop and plan nor block out their code into logical segments.
This article should help you see a way to block out your code by stubbing out the methods and logic, then filling in each method as you research it:
This is the 'Help me with my homework' article you wanted.



Resources, references and suggestions for new programmers. - Updated Mar 2012
Spoiler

This post has been edited by tlhIn`toq: 09 May 2012 - 03:32 PM

Was This Post Helpful? 2
  • +
  • -

#8 stonk  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 09-May 12

Re: Copying Forms In C#

Posted 09 May 2012 - 04:56 PM

Thanks a lot for all those links especially the Java ones, as im moving onto that next year and I dont wont to be stuck feeling the same way about that as I do with c#.

I'm already in the process of ordering some of the c# books as well as Java, because as you said I would be better off teaching myself this than waiting to be taught it.

I cant thank you enough for all your help.
Was This Post Helpful? 0
  • +
  • -

#9 h4nnib4l  Icon User is offline

  • The Noid
  • member icon

Reputation: 1181
  • View blog
  • Posts: 1,677
  • Joined: 24-August 11

Re: Copying Forms In C#

Posted 10 May 2012 - 05:57 AM

Fortunately, Java and C# are very similar syntactically. If you can get a solid grasp on OO principles from C#, learning Java will be a matter of learning the differences in the languages.

Everything I've learned about programming has come from projects, my own research, and from this forum. I'm actually pretty disgusted with my education (or I guess the fact that I learned very little from it), and if I hadn't had the GI Bill to pay for it, I would be even more offended that it actually cost money. That being said, you'll want that paper.

Languages are languages: you'll probably learn many over your career, but it's the ability to logically construct applications that we get paid for. Educate yourself and skulk around this forum, chiming in when you can. You'll learn a lot more. There's a lot of good information around here, and a lot of very knowledgeable people.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1