I'm trying to make an exact copy of form1 for further editing. I found many tutorials all with exactly the same advice. Copy the 3 files form1.designer.vb, form1.vb, and form1.resx. Paste and rename with form2 to replace form1 in the filenames. Then with a text editor I replaced (carefully and with a count) all instances of form1 with form2. Then I opened VS and selected show all and the new form2 appeared in solution explorer but without the form in design mode. The vb code was there, just not the form. Also, in solution explorer the outline of the form2 was dotted, not the icon displayed in form1, indicating something screwed up.
Again, I've seen at least 4 or 5 tutorials and 1 YT video, all from 2019 or later, all giving exactly the same advice above. Using Visual Studio 2019.
Ability to duplicate a form rather than recreate from scratch. Don't care about the code, just the form itself in design mode.
Ok, for anyone stumbling on this post, I found the problem. The VB code for form1 had a bindingsource which was copied to form2. Removing the references to bindingsource fixed the issue. Found this by pure fluke I guess, but that was it.
Related
My vb.net program was functioning properly. After I renamed Form1 in the code pane of Visual Studio 2015 the Program.vb[Design] pane will not open and the following message appears:
The class Form1 can be designed, but is not the first class in the file. Visual Studio requires that designers use the first class in the file. Move the class code so that it is the first class in the file and try loading the designer again.
The name change was in the first class (form) so I cannot move it further up.
Before the change there were no errors. After the change there are many handles clause, variable not declared and not a member of errors.
I had 2 choices for Startup form in the Application tab of My Project before the change. After I have only 1 choice from a dropdown list. Both choices were Class names.
Is there anything I can do to recover the Designer view? Should I just recreate the form?
Thanks in advance, for any suggestions.
form2.Hide() [ currently at Form 3 ]
form1.Close()
(different) form1.Close()
is there anyway, by any chance i can bring up the Form2 that is in Hide mode? from From 3? I have been looking around.
i had try to do Form2.Show(). However, the system inform me " Reference to a non-shared member requires an object reference ".
This project i am doing, I use pass information from 1 form to another.
From Form1 - 3 passing info the information have no prob. The problem now is that from Form3 i would like to re-display the Form2 (which is in Hide mode). but it do not allow me to do so. so far i see is that i can only type the code Form2.ActiveForm.Show(). am sorry for my long message. did really hope for help cause i can't find solution on the net. could be i fail to ask to make a hit on google
the answer so far can be found on this link given. please read through the commend for your details.
what is the different in form2.Close() and Form3.ActiveForm.Close() in VB
Not sure if its the best solution but if I understand you right.
If you were to have a "Globals" Module and add form2 as a variable in there:
Public Form2 As New Form2
You would then be able to control it from other forms without it becoming invalid e.g.
Global.Form2.Hide
Global.Form2.Show
And even modify the controls and values inside it from other forms:
Global.Form2.ThisLabel.Text = "TEXT"
This means form3 can have full control over your "form2" even while its hidden.
Okay, in Visual Studio 2012 I have a VB.NET project with originally two forms. Form1 was originally set as the startup form and then obsoleted. Form2 is a nearly identical form that has all of the new desirable functionality.
In my project's settings, Form2 doesn't appear as an available option for Startup Form. (Though it is a normally-created form that inherits Form) After some "troubleshooting," Form1 has been deleted, resulting in the the "Enable Application Framework" option being disabled and no Startup Object being available. When I select anything from the Startup Object drop-down, either Sub Main or Form2, I have an error message stating either "Sub Main not found in Solution" or "Form2 is a type in Solution and cannot be used as an expression" respectively. If I try to enable "Enable Application Framework," I receive an error popup stating "Startup object must be a form when 'Enable application framework' is checked." And Application.Designer.vb is empty.
Some things I've tried:
Clean and Rebuild Solution
Restarting Visual Studio
Temporarily deleting Form1 (it's still excluded from project)
Added a new form, per Neolisk's advice. It appeared in the available objects. I selected it and turned on application framework. From here, I copied the initialization code from Form2's designer code into Form3's. All was alright. Then, I copied Form2's main code into Form3. Now, "Form3 is a type in Solution and cannot be used as an expression" appears in my error list.
With that said, my question is how can I get Visual Studio to recognize my form as a form and set Form2 as the startup object?
add InitializeComponent() in new() function in form2
Found it! The issue was an overload of the form's constructor taking a form as a parameter. Since this was the only constructor in the file, I guess it caused confusion. Commented that out and all was right with the world again.
Sometimes you have a different class name from the form file name.
Check if the class name is listed.
I am trying to create a UserControl in VB.net, under VS2010. I have the code for the UserControl and I would like to add it to a form. My problem is that, according to every book and forum I have seen, after I build the UserControl, it should show up in the Toolbox. It doesn't. I even downloaded code from a book, the code executes perfectly, but their TrafficLight control doesn't go in the Toolbox (even though the book says it should - and that the only way to set its properties and to add it to the form is through the Control properties). I have tried to add the control to the form manually, by declaring it
Dim myObj As New SomeClass.SomeControl
and in the Designer.vb, identical with the buttons on the form:
Friend WithEvents myObj As SomeClass.SomeControl
With both, I get an error saying
'myObj' is already declared as 'Friend WithEvents myObj As SomeControl' in this class.
And either way, I get an error when I try to look at the design:
Could not find type 'SomeClass.SomeControl'. Please make sure that the assembly that contains this type is referenced. If this type is part of your development project, make sure the project has been successfully built using settings for your current platform or AnyCPU.
The control by itself builds and shows up in design view (not in the Toolbox though, even though it Imports System.ComponentModel and Inherits System.Windows.Forms.UserControl and... what else ? I tried to build it in a separate project, to see if I creating a separate dll will make a difference, though I really want it in the same project.
Please help ! (BTW I have reinstalled VS2010 and it did no good)
Thank you.
Look in Tools / Options / Windows Forms Designer and set "AutoToolboxPopulate" to True (but note that this can take a noticeable amount of time if you haver many (i.e. dozens) of user controls.
im having a similar problem like the solution here Prevent main form from appearing when showing another form . but some of the suggestions were to minimize the main app so it doesnt show, which i cant do because my main app is supposed to be a desktop to be underneath all other apps to replace the windows desktop. And the second forms are supposed to be sticky notes. so i cant minimize the main window cause it has the user background and other controls. i tried making the parent of the notes a Nothing pointer, a pointer to the desktop, creating the form through a dll but i had no success.
My main problem is that when i click a note (form2) form1 comes up, even with form1 having the WS_EX_NOACTIVATE in the createparams. form1 does the form2.show() but they shouldn't be attached.
Another reason im having trouble with the solutions preseted in that post is that they are for delphi and im doing it in vb.net.
All i need is being able to click on the controls and write in the note without bringing the main form behind the note. either making them independent, or making the note not focusing the first form or being able to operate the note without it activating. i dont know. my last resource is to attach my main form to the desktop but i've heard is the worst thing you can do because it can cause problems hanging the system.
If you want both forms to co-exist but don't each to interfere with the other: In this case, then you might want to have a third Form that calls both Form1 and Form2 to be opened, and let me suggest and MDI Form with Form1 and Form2 as children forms of the MDI form
'============== my previous post ========================
You can force the user to first dismiss Form2 then allow him to go back to form1 by showing Form2 as Modal form. Here is how to display Form2 as modal
Dim f2 as New Form2
f2.ShowModal()
If that does not work, try this
Dim f2 as New Form2
f2.Show(True)