From: Family Tree Mike on
On 4/25/2010 7:58 PM, Armin Zingler wrote:
> Am 26.04.2010 01:52, schrieb Mr. X.:
>> For the new form I don't get the code in *.Designer.vb, but on the
>> myForm.vb itself
>
> Right, that's what I wrote:
>>> Without using the Form template, the automatic code is always put in your
>>> own class file.
>
>> Is there any way to declare there is a designer behind (another vb) ?
>
> As I wrote:
>>> I don't know how the designer finds out where to put it,
>>> so I can't tell you if it were possible to force him to put it somewhere
>>> else.
>
>

From experimenting, it looks like you just need to add a class file,
named MyForm.Designer.vb, modfied as such:

partial class MyForm
Inherits System.Windows.Forms.Form

Private Sub InitializeComponent()
end sub
end class

The desinger canvas appears to just try and find the Initialize
component file and update that.

--
Mike
From: Cor Ligthert[MVP] on
What you see is the behaviour as it is for all versions of Net including Net
1.x.

The partial classes started at version 2.0, the designer templates generate
the designer.vb like it is with all this kind of generated classes (DataSet,
component, etc).



"Mr. X." <nospam(a)nospam_please.com> wrote in message
news:ucIT9lM5KHA.5880(a)TK2MSFTNGP04.phx.gbl...
> Hello.
> I have an inherited windows-form class : MyForm.
> When I put component on it - I see many code behind (and when I do on a
> original windows form, I don't get an automatic code behind).
>
> Form is declared :
> Public Class MyForm
> Inherits Form
>
> Public Sub New()
> MyClass.New(Nothing)
> End Sub
>
> Public Sub New(ByRef dt As DataTable)
> MyBase.New()
> ...
> End Sub
> End Class
>
> When I do another form like this (It is declared as a class) :
> Public Class frmTest
> Inherits MyForm
> ...
>
>
> When I just put a button on the form I get a auto-generated source on the
> code :
>
> Friend WithEvents Button1 As System.Windows.Forms.Button
> Private Sub InitializeComponent()
> Me.Button1 = New System.Windows.Forms.Button
> Me.SuspendLayout()
> '
> 'Button1
> '
> Me.Button1.Location = New System.Drawing.Point(506, 83)
> Me.Button1.Name = "Button1"
> Me.Button1.Size = New System.Drawing.Size(67, 58)
> Me.Button1.TabIndex = 0
> Me.Button1.Text = "Button1"
> Me.Button1.UseVisualStyleBackColor = True
> '
> 'frmTest
> '
> Me.ClientSize = New System.Drawing.Size(744, 218)
> Me.Controls.Add(Me.Button1)
> Me.Name = "frmTest"
> Me.ResumeLayout(False)
>
> End Sub
>
> Why I getting that automatic code, and how can I avid getting the
> auto-generated code behind (or see it elsewhere) ?
>
> Thanks :)
>
>
>
>
From: Mr. X. on
"Family Tree Mike" wrote :
---------------------------------
....
> partial class MyForm
> Inherits System.Windows.Forms.Form
>
> Private Sub InitializeComponent()
> end sub
> end class
>
> The desinger canvas appears to just try and find the Initialize component
> file and update that.
>
> --
> Mike

Hmm.
Seems too be very good solution - Thanks ...

I did that, but :
1. Still, when new controls, such as button, that are dropped onto the
form - new auto-generated code is on the myForm.vb code,
and not myForm.Designer.vb

2. How can I see the myForm.Designer.vb, if it is not shown on solution
explorer ?

Thanks :)

From: Family Tree Mike on
On 4/26/2010 3:52 PM, Mr. X. wrote:
> "Family Tree Mike" wrote :
> ---------------------------------
> ...
>> partial class MyForm
>> Inherits System.Windows.Forms.Form
>>
>> Private Sub InitializeComponent()
>> end sub
>> end class
>>
>> The desinger canvas appears to just try and find the Initialize
>> component file and update that.
>>
>> --
>> Mike
>
> Hmm.
> Seems too be very good solution - Thanks ...
>
> I did that, but :
> 1. Still, when new controls, such as button, that are dropped onto the
> form - new auto-generated code is on the myForm.vb code,
> and not myForm.Designer.vb
>
> 2. How can I see the myForm.Designer.vb, if it is not shown on solution
> explorer ?
>
> Thanks :)

Maybe manually fixing the .designer is a capability only in VS 2010
then. That's what I'm using. I will say that I created the .Designer
file before adding controls. Maybe you added some first?

Regarding seeing the .Designer.vb files, Armin already suggested an
answer. But, in the solution explorer, for me, the second button at the
top left is the "Show All Files" toggle button. It looks like three
pages of paper on a button. This enables the + or > depending on the
version of Visual Studio.

--
Mike
From: Mr. X. on
O.K.
(I have VS 2008)
Problem solved by the following way (not an elegant solution, anyway, and if
someone has other elegant way, I would like to hear about ...) :

What I did is simple, but I didn't find any other way :
Created a new form (not myForm, but a windows-form), put buttons on it, and
other components.
I get into the designer (I am searching the definition of initComponent
method, and didn't find other way), and only change the line :
Inherits System.Windows.Forms.Form
to :
Inherits MyForm.

Because MyForm is a child of System.Windows.Forms.Form, everything was
compiled fine, and also worked fine.

Thanks :)

First  |  Prev  | 
Pages: 1 2
Prev: Option strict
Next: Resize an image: bug?