Results 1 to 24 of 24

Thread: Forms under a project instead of solution

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2021
    Posts
    42

    Forms under a project instead of solution

    I am still not terribly familiar with Visual Studio and .NET. As a result, I put all my forms and modules in a solution instead of a project.

    (1) Was this stupid? Or it does not matter?

    (2) Is it easy to move them to a project?

    At present, I do not have solutions with more than one project. A solution and a project are the same for me at present. In Build also, I noticed that I could either build the project or the solution. I have not figured out which way is the best. I have been building the solution every time.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Forms under a project instead of solution

    I'm not sure that that is even possible. Can you post a screenshot of your Solution Explorer? I suspect that everything is actually in a project as it should be. All projects are part of a solution but, by default, when you create a new VB project, it will hide the solution and make the project the root node in the Solution Explorer. You probably just can't see the solution your project is in. I can't remember where it is off the top of my head but there's an option to specify that VB should always display the solution.

  3. #3

    Thread Starter
    Member
    Join Date
    Jul 2021
    Posts
    42

    Re: Forms under a project instead of solution

    Quote Originally Posted by jmcilhinney View Post
    I'm not sure that that is even possible. Can you post a screenshot of your Solution Explorer? I suspect that everything is actually in a project as it should be. All projects are part of a solution but, by default, when you create a new VB project, it will hide the solution and make the project the root node in the Solution Explorer. You probably just can't see the solution your project is in. I can't remember where it is off the top of my head but there's an option to specify that VB should always display the solution.
    This is how it looks.

    Attachment 182506

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Forms under a project instead of solution

    Your attachment is invalid. Not sure why this happens but I've seen it before. Try not attaching inline. Also, you may have already but ensure that you have just captured the relevant area and not your whole screen. Windows 10/11 have tools built in that allow you to select a specific area.

  5. #5

    Thread Starter
    Member
    Join Date
    Jul 2021
    Posts
    42

    Re: Forms under a project instead of solution

    Quote Originally Posted by jmcilhinney View Post
    Your attachment is invalid. Not sure why this happens but I've seen it before. Try not attaching inline. Also, you may have already but ensure that you have just captured the relevant area and not your whole screen. Windows 10/11 have tools built in that allow you to select a specific area.
    Please check again. The attachment is very much visible. I tried to insert an image and this is what it did. IT shows only the Solution explorer. Not the whole screen. And I am using Windows 7.

  6. #6
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,458

    Re: Forms under a project instead of solution

    Quote Originally Posted by VisualBeginner.NET View Post
    Please check again. The attachment is very much visible. I tried to insert an image and this is what it did. IT shows only the Solution explorer. Not the whole screen. And I am using Windows 7.
    The attachment isn't visible for me either.

  7. #7

    Thread Starter
    Member
    Join Date
    Jul 2021
    Posts
    42

    Re: Forms under a project instead of solution

    Quote Originally Posted by PlausiblyDamp View Post
    The attachment isn't visible for me either.
    How should I attach the image? Trying to insert it resulted in this.

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Forms under a project instead of solution

    As I already told you, try again but this time don't attach it inline. I'm not 100% sure but I think that that will prevent the issue.

  9. #9
    Fanatic Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    845

    Re: Forms under a project instead of solution

    Quote Originally Posted by VisualBeginner.NET View Post
    How should I attach the image? Trying to insert it resulted in this.
    go into advanced mode and use the "manage attachments" button
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
    “They did not know it was impossible so they did it” (Mark Twain)

  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Forms under a project instead of solution

    Quote Originally Posted by Delaney View Post
    go into advanced mode and use the "manage attachments" button
    Ah, it was probably done using the Insert Image function and that is probably broken, accounting for all the broken attachments I've seen over time. That never occurred to me as I've never done it that way myself.

  11. #11
    Fanatic Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    845

    Re: Forms under a project instead of solution

    I don't use "insert image" anymore in the quick reply. It almost never works.
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
    “They did not know it was impossible so they did it” (Mark Twain)

  12. #12
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,989

    Re: Forms under a project instead of solution

    Quote Originally Posted by VisualBeginner.NET View Post
    Please check again. The attachment is very much visible. I tried to insert an image and this is what it did. IT shows only the Solution explorer. Not the whole screen. And I am using Windows 7.
    So, you are seeing it?

    This is clearly an issue with the forum. As JMC noted, we've seen a LOT of these, lately. I don't upload images, so I have no experience with this, but it sure is common. It sounds like you may have some information about it, though, so you might post a thread in Forum Feedback about this. If you are seeing the image, that might be important. I believe that nobody else sees anything other than a link that says "Attachment 182506", and the link only takes you to a message saying something about an invalid attachment. Naturally, it's not good if there is a feature that isn't working. It's even LESS good if YOU see it as working and nobody else does, since that way you aren't getting what you are seeing.
    My usual boring signature: Nothing

  13. #13

    Thread Starter
    Member
    Join Date
    Jul 2021
    Posts
    42

    Re: Forms under a project instead of solution

    Quote Originally Posted by Delaney View Post
    go into advanced mode and use the "manage attachments" button
    Name:  SolutionExplorer20211006.png
Views: 197
Size:  18.1 KB

    Thanks. I think this should work.

  14. #14

    Thread Starter
    Member
    Join Date
    Jul 2021
    Posts
    42

    Re: Forms under a project instead of solution

    Quote Originally Posted by Shaggy Hiker View Post
    So, you are seeing it?

    This is clearly an issue with the forum. As JMC noted, we've seen a LOT of these, lately. I don't upload images, so I have no experience with this, but it sure is common. It sounds like you may have some information about it, though, so you might post a thread in Forum Feedback about this. If you are seeing the image, that might be important. I believe that nobody else sees anything other than a link that says "Attachment 182506", and the link only takes you to a message saying something about an invalid attachment. Naturally, it's not good if there is a feature that isn't working. It's even LESS good if YOU see it as working and nobody else does, since that way you aren't getting what you are seeing.
    That's right. It misleads me to believe that everything is fine.

  15. #15
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,458

    Re: Forms under a project instead of solution

    Quote Originally Posted by VisualBeginner.NET View Post
    Name:  SolutionExplorer20211006.png
Views: 197
Size:  18.1 KB

    Thanks. I think this should work.
    The forms and modules are all within a project called "NLS 050", which is inside a solution also called "NLS 050" - you don't need to do anything as all the files are indeed part of a project.

  16. #16

    Thread Starter
    Member
    Join Date
    Jul 2021
    Posts
    42

    Re: Forms under a project instead of solution

    Quote Originally Posted by PlausiblyDamp View Post
    The forms and modules are all within a project called "NLS 050", which is inside a solution also called "NLS 050" - you don't need to do anything as all the files are indeed part of a project.
    OK. Thanks. I added new forms by Add Form from Solution name. If I had two projects under this solution, which project would have received that new form? Sorry for very stupid questions. I don't find good introductory material on the Internet (and the result is that I have made minimal changes from VB6 so far - learning quite slowly).

  17. #17
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Forms under a project instead of solution

    Quote Originally Posted by VisualBeginner.NET View Post
    If I had two projects under this solution, which project would have received that new form?
    I don't think you can. If it let you do it with one project then it must be because there's no choice but I just tried adding a new item to a solution with multiple projects and there was no option to select a form. Just right-click a project to add a new item and there can be no confusion. You don't need to know what will happen if you do something that you can simply choose to never do. I've never found it a problem. Why would you?

  18. #18
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,989

    Re: Forms under a project instead of solution

    I haven't tried that, so I'd guess it would be the first one. I create folders for different things within the project. You can then Add Item (forms, classes, or any such thing) to the folders, let alone the project. You could do the same by adding to the project itself (which would add to the project, and not to any folder within the project). You can also drag and drop forms from one place to another in the Solution Explorer, so if you add folders after the fact, or create an object in the wrong place, then you can move them around, as needed. You could also add to both, though that seems likely to be a bad idea (two objects with the same name, even in different projects, is a bad idea).
    My usual boring signature: Nothing

  19. #19
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Forms under a project instead of solution

    Maybe this is a project provided by an instructor/teacher but the fact that you have forms and modules with meaningless names, distinguished by nothing but meaningless numbers, is very bad. I suspect that the controls on those forms have meaningless names as well. You should name everything descriptively when you add it. Everything should have a name that tells someone what it is for, even if they have no prior knowledge of the project. If I were an instructor, such names would lose you marks for making the project hard to understand.

  20. #20

    Thread Starter
    Member
    Join Date
    Jul 2021
    Posts
    42

    Re: Forms under a project instead of solution

    Quote Originally Posted by Shaggy Hiker View Post
    I haven't tried that, so I'd guess it would be the first one. I create folders for different things within the project. You can then Add Item (forms, classes, or any such thing) to the folders, let alone the project. You could do the same by adding to the project itself (which would add to the project, and not to any folder within the project). You can also drag and drop forms from one place to another in the Solution Explorer, so if you add folders after the fact, or create an object in the wrong place, then you can move them around, as needed. You could also add to both, though that seems likely to be a bad idea (two objects with the same name, even in different projects, is a bad idea).
    But how about one form (shared by) in two projects?

    And why did it put that bitmap there which was just supposed to be in one PictureBox?

  21. #21

    Thread Starter
    Member
    Join Date
    Jul 2021
    Posts
    42

    Re: Forms under a project instead of solution

    Quote Originally Posted by jmcilhinney View Post
    Maybe this is a project provided by an instructor/teacher but the fact that you have forms and modules with meaningless names, distinguished by nothing but meaningless numbers, is very bad. I suspect that the controls on those forms have meaningless names as well. You should name everything descriptively when you add it. Everything should have a name that tells someone what it is for, even if they have no prior knowledge of the project. If I were an instructor, such names would lose you marks for making the project hard to understand.
    This is for my own calculation work. The original in VB3 was started in 1996 and had the meaningless name Form1. Then came Form2 and it kept growing. And then some forms were removed. And the bad habit has continued until today. Even labels are Label1, Label2, etc. Not a good policy. There was nobody earlier to correct me. I have learnt all this on my own and in 1996, there were very few resources to learn VB3 from.

  22. #22
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,989

    Re: Forms under a project instead of solution

    Quote Originally Posted by VisualBeginner.NET View Post
    But how about one form (shared by) in two projects?

    And why did it put that bitmap there which was just supposed to be in one PictureBox?
    One form shared by two projects? Doesn't happen. Each project is an assemblage (and exe, dll, or some such). A form has a fully decorated name that includes the assemblage, such that you can have two different things in two different assemblages, which have the same name (the full name is different, kind of like two people with the same first name but not the same full name).

    As for the bitmap, it isn't in the picturebox, yet. It may be getting loaded by the picturebox, but it isn't part of the picturebox.
    My usual boring signature: Nothing

  23. #23
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Forms under a project instead of solution

    Quote Originally Posted by Shaggy Hiker View Post
    One form shared by two projects? Doesn't happen. Each project is an assemblage (and exe, dll, or some such). A form has a fully decorated name that includes the assemblage, such that you can have two different things in two different assemblages, which have the same name (the full name is different, kind of like two people with the same first name but not the same full name).
    That's not necessarily true. The fully qualified name of a type includes the namespace, not the assembly name. They are quite often the same but that's just a convenience. It is possible to add a new type to one project and then add an existing type to another project and add it as a link. That means that the type is part of the project but there's no source file in the project for it. I would generally tend to avoid doing this though. Generally speaking, if you want to share types then those types should be in a third project and the other two projects both reference that.

  24. #24
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: Forms under a project instead of solution

    Yeah, I did use a single form for two projects in a solution on my first application ever done in VB.Net. I was inexperienced with VB.Net, so had to learn quickly to get a project done for work.

    The project involved interfacing with hardware over a data bus which supported various numerical formats such as IEEE-32 and 64 bit formats (Singles and Doubles), a floating point format know as CAP48 and the Digital Equipment floating point formats for 4-byte and 8 byte floating point. It also supported various Fixed Point representations.

    To support testing of the conversions and packing of the data in messages, I created a form that allowed entering the byte values in Hex to be converted to the various formats and the various formats converted to be displayed in Hex. Plus basic math operations on the values.

    Since the form was so convenient for examining and converting between Hex and the various formats and vice versa, I thought it would be useful as a standalone executable that I could run independently of the full project it was "embedded" in.

    So, I guess I had the same question the OP had, and did a search and found how to do a link in a second project to the Form (named ToolKit) in the first project and voila, I could built that project and have a standalone form to support doing the conversions and calculations when needed independently of the original larger project which had that form as a embedded tool launched from a button press.

    Then if I added additional "tools" to the toolkit, I just do the change in the original big project, then build the solution to build both projects and have the capability in both projects.

    Of course, I've never had occasion to do that again as far as I can recall.

    p.s. Actually, I don't think it mattered which project I did the modification in. The filename for the form shows up in both projects, but are both referencing the same file location, so you can change it from either project. If you select it in one project and then choose it again from the other project it will look like it closes the previous instance and open up a new instance, but it is really the same instance, e.g. I can open the form in one project, and add a button, then double click on the form in the other project in the Solution Explorer and the form window will go away and then comeback, but the form will still have the button that was just added and still show that changes haven't been saved.
    It won't try to open the file twice in two windows of the IDE.
    Last edited by passel; Oct 6th, 2021 at 11:25 PM.
    "Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width