I just created a UserControl in my application, the problem I have is that every time I edit the code of UserControl I have to delete the UserControls already added to the GUI because it fails to compile.
The project / application is called Panel and UserControl called TimerPanel, which contains a couple of text boxes within a GroupBox.
The error reads
Type 'Panel.TimerPanel' is not defined.
The strange thing is that everything works OK until I edit the UserControl.
Like I said, if I delete the UserControl GUI, compiled and then added again to the GUI control, everything works OK.
I read somewhere on this forum that you must add a reference to System.Windows.Forms, and I did and it behaves the same.
What can I be doing wrong?
When you get that error go and build the project again, see if that fixes the issue (building a project again fixes lots of errors and when you add/change a user control is needed to use it)
Related
I was commenting out code in my project and starting getting errors in the designer which stopped me from viewing the page.
After this i decided to put everything back so I was able to run the program again. (Yes, i have made sure to comment everything back)
I am now getting designer errors on some of my pages. Here is the errors and examples.
Here is the list of errors I am getting:
http://i.stack.imgur.com/NFX8G.png
The application does run but if i click on the frmMediaDevices1.vb page this is the errors that then appears:
http://i.stack.imgur.com/XZrPE.png
I think it maybe something to do with the Windows.Media.Player that i have referenced in the project on frmMain.vb as when I click the errors the designer code appears highlighting my media player on the page.
Does anyone know how I can maybe refresh the designer? Or know how i can fix this issue?
Form's class must be the first in the form's class module.
Problem you described happens if you have files like
Form1.designer.vb
Form1.vb
Form1.resx
and into file Form1.vb which contains Class Form1 you add class Class Helper1. You can do it, but class Form1 must be kept as the first class (tompost in code) in Form1.vb.
Of course, this also includes the case if you have only one (proper) class in the file (Class Form1), but you comment it out.
Just be careful with your commenting and you will avoid that error.
I have been working with "visual basic.net" on a "windows forms" application. While manipulating controls and adding event handlers I noticed the resultant code was being generated within a file named 'main.designer.vb'. However, if I look in the solution explorer for my project there is no 'main.designer.vb' file, just 'main.vb'.
This is not a colossal problem as it runs properly. However, having closed the 'form designer' window I now cannot reopen it! 'main.vb' has no option to 'view in form designer'.
Any advice on this?
Would it be possible to copy the contents of 'main.designer.vb' in to 'main.vb' and delete 'main.designer.vb' entirely? If I did this, the next time I manipulated the form would the code be added to 'main.vb' or would a new 'main.designer.vb' be created?
I seem to have sorted out the problem.
'main.vb' was completely empty. All the code I had generated and written directly was inside 'main.designer.vb'. However, once I made a class definition within 'main.vb':
Public Class main
End Class
and then cut/pasted all my custom event handler code and subroutines from 'main.designer.vb' to THAT class - all was well. 'main.vb' now shows the correct form icon and FINALLY offers the correct 'view designer' context menu option.
I am not sure why it happened in the first place though.
Look in the Solution Explorer in Visual Studio. In the toolbar in this window is a button called "Show all files". Click it.
Then every file in the projects folder is actually shown in the solution explorer. Expand the treenodes for the form and you will see the designer.vb.
There are also buttons for switching between code-view and designer view. Just remember to select the form in the solution explorer for the buttons to show the correct form in the designer.
I have a panel contains many controls, the designer file has its code and I can not find them on the form and I can not see them on document outline window although when trying to add a new panel with same name I get an error saying 'The name wowPanel is already in use by another component.'
What can I do to resolve this issue?
I replaced my designer file with an old version then everything goes very well.
Look for all instances in your form code where you have the name/text wowPanel
REM out these lines temporarily
REM out any subroutines if you have event subroutines for the wowpanel
Next add the new wowPanel and Name it as so "wowPanel"
Now UN-REM (un-remark) all the code statements you REMmed out earlier.
That ought to do it.
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.
I am trying to create a Windows Phone app that will take use a similar UI element in multiple user controls.
One user control is loaded by the main xaml and this user control consists of another user controls. The user controls are all in the same directory below where the main xaml exists.
I get an XamlParseException on the following line in my g.i.cs file for the nested control:
System.Windows.Application.LoadComponent(this, new System.Uri("/MyApp;component/UI/NestedControl.xaml", System.UriKind.Relative));
I think it is doubling the component/UI portions of the path as the parent user control already resides in this directory.
Does anyone know how to solve this?
This exception typically means that the XAML parser cannot find the referenced XAML, or that you have invalid XAML for your NestedControl class.
Without further code, it is hard to determine the root cause. I would suggest deleting these classes until your project compiles, then slowly adding them back again, compiling each time. This will help you identify where the problem lies.