|
-
Oct 23rd, 2009, 10:54 AM
#1
Thread Starter
Addicted Member
Why has my UserControl changed to a Class?
I've been working on a project that has a few UserControls, all put onto my main form. Recently one of my UserControls has changed into a class (icon in Solution Explorer has changed). I can no longer edit the Designer (GUI) of it. Why has this happened. I first noticed it when I opened the program for edit last, it opened all the window tabs that I was using before (including the GUI designer for that UserControl). When I would double click on an object in that UserControl (in designer mode), it would take me to the Designer text code, not my actual code and everything in my actual code stopped working, and it would only execute subs written in the designer code. What is going on here? How do I get it back?
Thank-you for your help!
-
Oct 23rd, 2009, 11:28 AM
#2
Re: Why has my UserControl changed to a Class?
Are the <usercontrol name>.Designer.vb and <usercontrol name.resx files still there? Check if they appear in the solution explorer. Usually they should appear underneath the main usercontrol node (if Show All Files is enabled), but sometimes I found it can happen that they get 'detached' and simply show up amongst the other files. When that happens all you need to do is re-add them to your project.
I usually go to the project folder and copy/paste the 3 relevant files (.vb, .Designer.vb and .resx) and paste them to my desktop (or some other temp directory). Then I delete the files from within Visual Studio. Then I use Add - Existing Item to add the three files back. If all goes well they will once again be grouped under the main file in the solution explorer.
-
Oct 23rd, 2009, 01:57 PM
#3
Thread Starter
Addicted Member
Re: Why has my UserControl changed to a Class?
@NickThissen - Yes they were under the UserControl that has the issue. I copied/paste them for back-up, then deleted them through the Solution Explorer. I then copy/paste them back into the application directory, and then added them back into the project. No change. I saved the project, then exited VB. I returned back to my project, no change. Not sure if it will help, but I've included the Control.Designer.vb contents. If it means anything, I did call the MusicControl.AxWindowsMediaPlayer1 from other usercontrols and the main form. Maybe a UserControl changing another usercontrol object did it?
Code:
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class MusicControl
Inherits System.Windows.Forms.UserControl
'UserControl overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(MusicControl))
Me.AxWindowsMediaPlayer1 = New AxWMPLib.AxWindowsMediaPlayer
Me.ListBox1 = New System.Windows.Forms.ListBox
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
CType(Me.AxWindowsMediaPlayer1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'AxWindowsMediaPlayer1
'
Me.AxWindowsMediaPlayer1.Enabled = True
Me.AxWindowsMediaPlayer1.Location = New System.Drawing.Point(535, 3)
Me.AxWindowsMediaPlayer1.Name = "AxWindowsMediaPlayer1"
Me.AxWindowsMediaPlayer1.OcxState = CType(resources.GetObject("AxWindowsMediaPlayer1.OcxState"), System.Windows.Forms.AxHost.State)
Me.AxWindowsMediaPlayer1.Size = New System.Drawing.Size(212, 212)
Me.AxWindowsMediaPlayer1.TabIndex = 0
'
'ListBox1
'
Me.ListBox1.BackColor = System.Drawing.Color.Black
Me.ListBox1.Font = New System.Drawing.Font("Arial Black", 20.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ListBox1.ForeColor = System.Drawing.Color.White
Me.ListBox1.FormattingEnabled = True
Me.ListBox1.ItemHeight = 38
Me.ListBox1.Location = New System.Drawing.Point(-2, -2)
Me.ListBox1.Name = "ListBox1"
Me.ListBox1.Size = New System.Drawing.Size(535, 460)
Me.ListBox1.TabIndex = 1
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(597, 371)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(60, 76)
Me.Button1.TabIndex = 3
Me.Button1.Text = "Button1"
Me.Button1.UseVisualStyleBackColor = True
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(535, 371)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(60, 76)
Me.Button2.TabIndex = 4
Me.Button2.Text = "Button2"
Me.Button2.UseVisualStyleBackColor = True
'
'MusicControl
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.BackColor = System.Drawing.Color.Gray
Me.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.ListBox1)
Me.Controls.Add(Me.AxWindowsMediaPlayer1)
Me.ForeColor = System.Drawing.Color.White
Me.Name = "MusicControl"
Me.Size = New System.Drawing.Size(750, 450)
CType(Me.AxWindowsMediaPlayer1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
Friend WithEvents AxWindowsMediaPlayer1 As AxWMPLib.AxWindowsMediaPlayer
Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
End Class
The control.resx, reads:
Name: AxWindowsMediaPlay1.OcxState
Type: System.Windows.Forms.AxHost+State
Value: (Value cannot be displayed)
Now, I'm most likely going to re-do this Control anyways (not liking how I have it coded) How-ever I would like to know that I did, so I dont FUBAR another Control.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|