HELP!! - How to add a simple custum control to the VS.NET toolbox?

M

Mobile Boy 36

I read the articles http://www.intelliprog.com/articles/index.html and the
Microsoft Simple chart demo...
But without success...By the way, I'm using VB.net...
Does someone have a complete document describing how to add a control
(written in Vb.NET or eventually in C#) to the controlbox of Visual Studio?

The control MyTextBox is a textbox that inherits from the TextBox class and
adds 2 properties...
It's working fine when I create the control at runtime...
My aim is to put 'MyTextBox' on the VS toolbar. but how do you do this??????
Please can someone help...

I was using the commandline compliler vbc from within a batchfile
"BuildMyControl.bat" to make
the Design.MyTextBox.dll but this does not succeed.

The folowing files are located in one directory:

BuildMyControl.bat
MyTextBox.dll
MyTextBox.vb
System.CF.Design.dll
System.CF.Drawing.DLL
System.CF.Windows.Forms.dll

In C# you have to add something like
#If NETCFDESIGNTIME Then
[
System.ComponentModel.Category("Colours"),
System.ComponentModel.Description("This our colours")
]
#End If
What is the equivalent in VB ?


THIS IS MY CODE (What is wrong with it? The compiler from Visual Studio
doesn't repport errors)

#If NETCFDESIGNTIME Then
[assembly: System.CF.Design.RuntimeAssemblyAttribute("MyTextBoxControl,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")]
#End If

Namespace MyTextBoxControl

Public Class cdaTextBox
Inherits TextBox

#Region "Private data members"
Private mFocusColor As System.Drawing.Color =
System.Drawing.Color.Blue
Private mFocusTextColor As System.Drawing.Color =
System.Drawing.Color.Yellow

Private mOriginalColor As System.Drawing.Color
Private mOrinalTextColor As System.Drawing.Color

#End Region

#Region "Properties!"


#If NETCFDESIGNTIME Then
[
System.ComponentModel.Category("Colours"),
System.ComponentModel.Description("This our colours")
]
#End If
Property FocusColor() As System.Drawing.Color
Get
FocusColor = mFocusColor
End Get
Set(ByVal Value As System.Drawing.Color)
mFocusColor = Value
End Set
End Property


#If NETCFDESIGNTIME Then
[
System.ComponentModel.Category("Colours"),
System.ComponentModel.Description("This our colours")
]
#End If

Property FocusTextColor() As System.Drawing.Color
Get
FocusTextColor = mFocusTextColor
End Get
Set(ByVal Value As System.Drawing.Color)
mFocusTextColor = Value
End Set
End Property

#End Region

Protected Overrides Sub onGotFocus(ByVal e As System.EventArgs)
mOriginalColor = Me.BackColor
mOrinalTextColor = Me.ForeColor
Me.BackColor = mFocusColor
Me.ForeColor = mFocusTextColor
End Sub

Protected Overrides Sub onLostFocus(ByVal e As System.EventArgs)
Me.BackColor = mOriginalColor
Me.ForeColor = mOrinalTextColor
End Sub

End Class
End Namespace


Best regards,
Mobile Boy
 
C

Chris Tacke, eMVP

I don't believe you can get designer support with a control authored in VB.

--
Chris Tacke, eMVP
Co-Founder and Advisory Board Member
www.OpenNETCF.org
---
Windows CE Product Manager
Applied Data Systems
www.applieddata.net


Mobile Boy 36 said:
I read the articles http://www.intelliprog.com/articles/index.html and the
Microsoft Simple chart demo...
But without success...By the way, I'm using VB.net...
Does someone have a complete document describing how to add a control
(written in Vb.NET or eventually in C#) to the controlbox of Visual Studio?

The control MyTextBox is a textbox that inherits from the TextBox class and
adds 2 properties...
It's working fine when I create the control at runtime...
My aim is to put 'MyTextBox' on the VS toolbar. but how do you do this??????
Please can someone help...

I was using the commandline compliler vbc from within a batchfile
"BuildMyControl.bat" to make
the Design.MyTextBox.dll but this does not succeed.

The folowing files are located in one directory:

BuildMyControl.bat
MyTextBox.dll
MyTextBox.vb
System.CF.Design.dll
System.CF.Drawing.DLL
System.CF.Windows.Forms.dll

In C# you have to add something like
#If NETCFDESIGNTIME Then
[
System.ComponentModel.Category("Colours"),
System.ComponentModel.Description("This our colours")
]
#End If
What is the equivalent in VB ?


THIS IS MY CODE (What is wrong with it? The compiler from Visual Studio
doesn't repport errors)

#If NETCFDESIGNTIME Then
[assembly: System.CF.Design.RuntimeAssemblyAttribute("MyTextBoxControl,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")]
#End If

Namespace MyTextBoxControl

Public Class cdaTextBox
Inherits TextBox

#Region "Private data members"
Private mFocusColor As System.Drawing.Color =
System.Drawing.Color.Blue
Private mFocusTextColor As System.Drawing.Color =
System.Drawing.Color.Yellow

Private mOriginalColor As System.Drawing.Color
Private mOrinalTextColor As System.Drawing.Color

#End Region

#Region "Properties!"


#If NETCFDESIGNTIME Then
[
System.ComponentModel.Category("Colours"),
System.ComponentModel.Description("This our colours")
]
#End If
Property FocusColor() As System.Drawing.Color
Get
FocusColor = mFocusColor
End Get
Set(ByVal Value As System.Drawing.Color)
mFocusColor = Value
End Set
End Property


#If NETCFDESIGNTIME Then
[
System.ComponentModel.Category("Colours"),
System.ComponentModel.Description("This our colours")
]
#End If

Property FocusTextColor() As System.Drawing.Color
Get
FocusTextColor = mFocusTextColor
End Get
Set(ByVal Value As System.Drawing.Color)
mFocusTextColor = Value
End Set
End Property

#End Region

Protected Overrides Sub onGotFocus(ByVal e As System.EventArgs)
mOriginalColor = Me.BackColor
mOrinalTextColor = Me.ForeColor
Me.BackColor = mFocusColor
Me.ForeColor = mFocusTextColor
End Sub

Protected Overrides Sub onLostFocus(ByVal e As System.EventArgs)
Me.BackColor = mOriginalColor
Me.ForeColor = mOrinalTextColor
End Sub

End Class
End Namespace


Best regards,
Mobile Boy
 
M

Mobile Boy 36

Ok chris,

Is my procedure, the way I'm following, ok ?
Lets say I rewrite the control in C# and I use csc.exe instead
of vbc.exe.


Chris Tacke said:
I don't believe you can get designer support with a control authored in VB.

--
Chris Tacke, eMVP
Co-Founder and Advisory Board Member
www.OpenNETCF.org
---
Windows CE Product Manager
Applied Data Systems
www.applieddata.net


Mobile Boy 36 said:
I read the articles http://www.intelliprog.com/articles/index.html and the
Microsoft Simple chart demo...
But without success...By the way, I'm using VB.net...
Does someone have a complete document describing how to add a control
(written in Vb.NET or eventually in C#) to the controlbox of Visual Studio?

The control MyTextBox is a textbox that inherits from the TextBox class and
adds 2 properties...
It's working fine when I create the control at runtime...
My aim is to put 'MyTextBox' on the VS toolbar. but how do you do this??????
Please can someone help...

I was using the commandline compliler vbc from within a batchfile
"BuildMyControl.bat" to make
the Design.MyTextBox.dll but this does not succeed.

The folowing files are located in one directory:

BuildMyControl.bat
MyTextBox.dll
MyTextBox.vb
System.CF.Design.dll
System.CF.Drawing.DLL
System.CF.Windows.Forms.dll

In C# you have to add something like
#If NETCFDESIGNTIME Then
[
System.ComponentModel.Category("Colours"),
System.ComponentModel.Description("This our colours")
]
#End If
What is the equivalent in VB ?


THIS IS MY CODE (What is wrong with it? The compiler from Visual Studio
doesn't repport errors)

#If NETCFDESIGNTIME Then
[assembly: System.CF.Design.RuntimeAssemblyAttribute("MyTextBoxControl,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")]
#End If

Namespace MyTextBoxControl

Public Class cdaTextBox
Inherits TextBox

#Region "Private data members"
Private mFocusColor As System.Drawing.Color =
System.Drawing.Color.Blue
Private mFocusTextColor As System.Drawing.Color =
System.Drawing.Color.Yellow

Private mOriginalColor As System.Drawing.Color
Private mOrinalTextColor As System.Drawing.Color

#End Region

#Region "Properties!"


#If NETCFDESIGNTIME Then
[
System.ComponentModel.Category("Colours"),
System.ComponentModel.Description("This our colours")
]
#End If
Property FocusColor() As System.Drawing.Color
Get
FocusColor = mFocusColor
End Get
Set(ByVal Value As System.Drawing.Color)
mFocusColor = Value
End Set
End Property


#If NETCFDESIGNTIME Then
[
System.ComponentModel.Category("Colours"),
System.ComponentModel.Description("This our colours")
]
#End If

Property FocusTextColor() As System.Drawing.Color
Get
FocusTextColor = mFocusTextColor
End Get
Set(ByVal Value As System.Drawing.Color)
mFocusTextColor = Value
End Set
End Property

#End Region

Protected Overrides Sub onGotFocus(ByVal e As System.EventArgs)
mOriginalColor = Me.BackColor
mOrinalTextColor = Me.ForeColor
Me.BackColor = mFocusColor
Me.ForeColor = mFocusTextColor
End Sub

Protected Overrides Sub onLostFocus(ByVal e As System.EventArgs)
Me.BackColor = mOriginalColor
Me.ForeColor = mOrinalTextColor
End Sub

End Class
End Namespace


Best regards,
Mobile Boy
 
D

Dan Fergus

You can do it with VB. I believe the batch file that you referenced will
work properly. Here is a snippet from one of my C# controls

#if NETCFDESIGNTIME
[
System.ComponentModel.Category("Appearance"),
System.ComponentModel.Description("The color for the Calendar caption font")
]
#endif
public Color ButtonColor
{
get
{
return _btnColor;
}
set
{
_btnColor = value;
}
}

Once built you right click on the toolbox, select 'Add/Remove Items' and
popint to your design time version of the control
--
Dan Fergus - eMVP
Forest Software Group
The Definitive Guide to the .NET Compact Framework

Mobile Boy 36 said:
Ok chris,

Is my procedure, the way I'm following, ok ?
Lets say I rewrite the control in C# and I use csc.exe instead
of vbc.exe.


Chris Tacke said:
I don't believe you can get designer support with a control authored in VB.

--
Chris Tacke, eMVP
Co-Founder and Advisory Board Member
www.OpenNETCF.org
---
Windows CE Product Manager
Applied Data Systems
www.applieddata.net


Mobile Boy 36 said:
I read the articles http://www.intelliprog.com/articles/index.html and the
Microsoft Simple chart demo...
But without success...By the way, I'm using VB.net...
Does someone have a complete document describing how to add a control
(written in Vb.NET or eventually in C#) to the controlbox of Visual Studio?

The control MyTextBox is a textbox that inherits from the TextBox
class
and
adds 2 properties...
It's working fine when I create the control at runtime...
My aim is to put 'MyTextBox' on the VS toolbar. but how do you do this??????
Please can someone help...

I was using the commandline compliler vbc from within a batchfile
"BuildMyControl.bat" to make
the Design.MyTextBox.dll but this does not succeed.

The folowing files are located in one directory:

BuildMyControl.bat
MyTextBox.dll
MyTextBox.vb
System.CF.Design.dll
System.CF.Drawing.DLL
System.CF.Windows.Forms.dll

In C# you have to add something like
#If NETCFDESIGNTIME Then
[
System.ComponentModel.Category("Colours"),
System.ComponentModel.Description("This our colours")
]
#End If
What is the equivalent in VB ?


THIS IS MY CODE (What is wrong with it? The compiler from Visual Studio
doesn't repport errors)

#If NETCFDESIGNTIME Then
[assembly: System.CF.Design.RuntimeAssemblyAttribute("MyTextBoxControl,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")]
#End If

Namespace MyTextBoxControl

Public Class cdaTextBox
Inherits TextBox

#Region "Private data members"
Private mFocusColor As System.Drawing.Color =
System.Drawing.Color.Blue
Private mFocusTextColor As System.Drawing.Color =
System.Drawing.Color.Yellow

Private mOriginalColor As System.Drawing.Color
Private mOrinalTextColor As System.Drawing.Color

#End Region

#Region "Properties!"


#If NETCFDESIGNTIME Then
[
System.ComponentModel.Category("Colours"),
System.ComponentModel.Description("This our colours")
]
#End If
Property FocusColor() As System.Drawing.Color
Get
FocusColor = mFocusColor
End Get
Set(ByVal Value As System.Drawing.Color)
mFocusColor = Value
End Set
End Property


#If NETCFDESIGNTIME Then
[
System.ComponentModel.Category("Colours"),
System.ComponentModel.Description("This our colours")
]
#End If

Property FocusTextColor() As System.Drawing.Color
Get
FocusTextColor = mFocusTextColor
End Get
Set(ByVal Value As System.Drawing.Color)
mFocusTextColor = Value
End Set
End Property

#End Region

Protected Overrides Sub onGotFocus(ByVal e As System.EventArgs)
mOriginalColor = Me.BackColor
mOrinalTextColor = Me.ForeColor
Me.BackColor = mFocusColor
Me.ForeColor = mFocusTextColor
End Sub

Protected Overrides Sub onLostFocus(ByVal e As System.EventArgs)
Me.BackColor = mOriginalColor
Me.ForeColor = mOrinalTextColor
End Sub

End Class
End Namespace


Best regards,
Mobile Boy
 
M

Mobile Boy 36

Fergus,

Can you do it with vb?
Do you need a option for the command line compiler?
On http://www.intelliprog.com/articles/index.html they use
csc.exe /o. But I can't find a /o option when I cal csc.exe/?
And what about
[
System.ComponentModel.Category("Appearance"),
System.ComponentModel.Description("The color for the Calendar caption
font")
]

in VB.net. Is the 'synthax' the same?
What commandline option do I need for the vbc commandlinecompiler ?

best regards,
MobileBoy

Dan Fergus said:
You can do it with VB. I believe the batch file that you referenced will
work properly. Here is a snippet from one of my C# controls

#if NETCFDESIGNTIME
[
System.ComponentModel.Category("Appearance"),
System.ComponentModel.Description("The color for the Calendar caption font")
]
#endif
public Color ButtonColor
{
get
{
return _btnColor;
}
set
{
_btnColor = value;
}
}

Once built you right click on the toolbox, select 'Add/Remove Items' and
popint to your design time version of the control
--
Dan Fergus - eMVP
Forest Software Group
The Definitive Guide to the .NET Compact Framework

Mobile Boy 36 said:
Ok chris,

Is my procedure, the way I'm following, ok ?
Lets say I rewrite the control in C# and I use csc.exe instead
of vbc.exe.


Chris Tacke said:
I don't believe you can get designer support with a control authored
in
VB.
--
Chris Tacke, eMVP
Co-Founder and Advisory Board Member
www.OpenNETCF.org
---
Windows CE Product Manager
Applied Data Systems
www.applieddata.net


I read the articles http://www.intelliprog.com/articles/index.html
and
the
Microsoft Simple chart demo...
But without success...By the way, I'm using VB.net...
Does someone have a complete document describing how to add a control
(written in Vb.NET or eventually in C#) to the controlbox of Visual
Studio?

The control MyTextBox is a textbox that inherits from the TextBox class
and
adds 2 properties...
It's working fine when I create the control at runtime...
My aim is to put 'MyTextBox' on the VS toolbar. but how do you do
this??????
Please can someone help...

I was using the commandline compliler vbc from within a batchfile
"BuildMyControl.bat" to make
the Design.MyTextBox.dll but this does not succeed.

The folowing files are located in one directory:

BuildMyControl.bat
MyTextBox.dll
MyTextBox.vb
System.CF.Design.dll
System.CF.Drawing.DLL
System.CF.Windows.Forms.dll

In C# you have to add something like
#If NETCFDESIGNTIME Then
[
System.ComponentModel.Category("Colours"),
System.ComponentModel.Description("This our colours")
]
#End If
What is the equivalent in VB ?


THIS IS MY CODE (What is wrong with it? The compiler from Visual Studio
doesn't repport errors)

#If NETCFDESIGNTIME Then
[assembly: System.CF.Design.RuntimeAssemblyAttribute("MyTextBoxControl,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")]
#End If

Namespace MyTextBoxControl

Public Class cdaTextBox
Inherits TextBox

#Region "Private data members"
Private mFocusColor As System.Drawing.Color =
System.Drawing.Color.Blue
Private mFocusTextColor As System.Drawing.Color =
System.Drawing.Color.Yellow

Private mOriginalColor As System.Drawing.Color
Private mOrinalTextColor As System.Drawing.Color

#End Region

#Region "Properties!"


#If NETCFDESIGNTIME Then
[
System.ComponentModel.Category("Colours"),
System.ComponentModel.Description("This our colours")
]
#End If
Property FocusColor() As System.Drawing.Color
Get
FocusColor = mFocusColor
End Get
Set(ByVal Value As System.Drawing.Color)
mFocusColor = Value
End Set
End Property


#If NETCFDESIGNTIME Then
[
System.ComponentModel.Category("Colours"),
System.ComponentModel.Description("This our colours")
]
#End If

Property FocusTextColor() As System.Drawing.Color
Get
FocusTextColor = mFocusTextColor
End Get
Set(ByVal Value As System.Drawing.Color)
mFocusTextColor = Value
End Set
End Property

#End Region

Protected Overrides Sub onGotFocus(ByVal e As System.EventArgs)
mOriginalColor = Me.BackColor
mOrinalTextColor = Me.ForeColor
Me.BackColor = mFocusColor
Me.ForeColor = mFocusTextColor
End Sub

Protected Overrides Sub onLostFocus(ByVal e As System.EventArgs)
Me.BackColor = mOriginalColor
Me.ForeColor = mOrinalTextColor
End Sub

End Class
End Namespace


Best regards,
Mobile Boy
 
D

Dan Fergus

Sorry, I think I may have said that wrong or it came out of my fingers
worng, You ca NOT make a control for design time with VB.NET on the CF. You
can create one, instantiaite it at run time and access it's properties
normally.

The problem I always have with this is that ther is no visual way to account
for the space in the designer. My way around it is to put a label (or a
panel or something else) on the form in the location of the control I will
add at run-time. Then in the forms load event I create the VB control, set
it's location and size to those of the temporary control and then remove the
temporrary control from the form.

There is no way to get around the compiler 'problem' (VB makes it an error,
C# only a warning). If VB only made it a warning then you would be alright
but it doesn't so you have to use C#.

--
Dan Fergus - eMVP
Forest Software Group
The Definitive Guide to the .NET Compact Framework

Mobile Boy 36 said:
Fergus,

Can you do it with vb?
Do you need a option for the command line compiler?
On http://www.intelliprog.com/articles/index.html they use
csc.exe /o. But I can't find a /o option when I cal csc.exe/?
And what about
[
System.ComponentModel.Category("Appearance"),
System.ComponentModel.Description("The color for the Calendar caption
font")
]

in VB.net. Is the 'synthax' the same?
What commandline option do I need for the vbc commandlinecompiler ?

best regards,
MobileBoy

Dan Fergus said:
You can do it with VB. I believe the batch file that you referenced will
work properly. Here is a snippet from one of my C# controls

#if NETCFDESIGNTIME
[
System.ComponentModel.Category("Appearance"),
System.ComponentModel.Description("The color for the Calendar caption font")
]
#endif
public Color ButtonColor
{
get
{
return _btnColor;
}
set
{
_btnColor = value;
}
}

Once built you right click on the toolbox, select 'Add/Remove Items' and
popint to your design time version of the control
--
Dan Fergus - eMVP
Forest Software Group
The Definitive Guide to the .NET Compact Framework

Mobile Boy 36 said:
Ok chris,

Is my procedure, the way I'm following, ok ?
Lets say I rewrite the control in C# and I use csc.exe instead
of vbc.exe.


I don't believe you can get designer support with a control authored in
VB.

--
Chris Tacke, eMVP
Co-Founder and Advisory Board Member
www.OpenNETCF.org
---
Windows CE Product Manager
Applied Data Systems
www.applieddata.net


I read the articles http://www.intelliprog.com/articles/index.html and
the
Microsoft Simple chart demo...
But without success...By the way, I'm using VB.net...
Does someone have a complete document describing how to add a control
(written in Vb.NET or eventually in C#) to the controlbox of Visual
Studio?

The control MyTextBox is a textbox that inherits from the TextBox class
and
adds 2 properties...
It's working fine when I create the control at runtime...
My aim is to put 'MyTextBox' on the VS toolbar. but how do you do
this??????
Please can someone help...

I was using the commandline compliler vbc from within a batchfile
"BuildMyControl.bat" to make
the Design.MyTextBox.dll but this does not succeed.

The folowing files are located in one directory:

BuildMyControl.bat
MyTextBox.dll
MyTextBox.vb
System.CF.Design.dll
System.CF.Drawing.DLL
System.CF.Windows.Forms.dll

In C# you have to add something like
#If NETCFDESIGNTIME Then
[
System.ComponentModel.Category("Colours"),
System.ComponentModel.Description("This our colours")
]
#End If
What is the equivalent in VB ?


THIS IS MY CODE (What is wrong with it? The compiler from Visual Studio
doesn't repport errors)

#If NETCFDESIGNTIME Then
[assembly: System.CF.Design.RuntimeAssemblyAttribute("MyTextBoxControl,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")]
#End If

Namespace MyTextBoxControl

Public Class cdaTextBox
Inherits TextBox

#Region "Private data members"
Private mFocusColor As System.Drawing.Color =
System.Drawing.Color.Blue
Private mFocusTextColor As System.Drawing.Color =
System.Drawing.Color.Yellow

Private mOriginalColor As System.Drawing.Color
Private mOrinalTextColor As System.Drawing.Color

#End Region

#Region "Properties!"


#If NETCFDESIGNTIME Then
[
System.ComponentModel.Category("Colours"),
System.ComponentModel.Description("This our colours")
]
#End If
Property FocusColor() As System.Drawing.Color
Get
FocusColor = mFocusColor
End Get
Set(ByVal Value As System.Drawing.Color)
mFocusColor = Value
End Set
End Property


#If NETCFDESIGNTIME Then
[
System.ComponentModel.Category("Colours"),
System.ComponentModel.Description("This our colours")
]
#End If

Property FocusTextColor() As System.Drawing.Color
Get
FocusTextColor = mFocusTextColor
End Get
Set(ByVal Value As System.Drawing.Color)
mFocusTextColor = Value
End Set
End Property

#End Region

Protected Overrides Sub onGotFocus(ByVal e As System.EventArgs)
mOriginalColor = Me.BackColor
mOrinalTextColor = Me.ForeColor
Me.BackColor = mFocusColor
Me.ForeColor = mFocusTextColor
End Sub

Protected Overrides Sub onLostFocus(ByVal e As System.EventArgs)
Me.BackColor = mOriginalColor
Me.ForeColor = mOrinalTextColor
End Sub

End Class
End Namespace


Best regards,
Mobile Boy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top