Groups | Blog | Home
all groups > dotnet compact framework > july 2005 >

dotnet compact framework : toolbox ready CF custom controls for VS 2005?


notu
7/28/2005 4:45:34 PM
Hi

I have several custom controls developed for VS 2003 that can be added to
the toolbox. I would like to compile these controls for VS 2005 Beta 2. Can
this be done? Where can i find documentation on this. Do I still have to
build dlls for the designer?

Thanks
;)

Tim Wilson
7/28/2005 6:53:20 PM
There's not a whole lot of information floating around, yet, about the way
custom controls for devices are built using VS 2005. The short answer is
that you no longer need to build a design-time assembly manually to include
design-time attributes as this is now done using a special XML-based file.
One resource that you may want to look into, however, is the "Creating
Custom Controls for Managed Code with Design Time Support in Visual Studio
2005" webcast that was done not too long ago.
http://msevents.microsoft.com/cui/WebCastEventDetails.aspx?EventID=1032277944&EventCategory=5&culture=en-US&CountryCode=US

--
Tim Wilson
..Net Compact Framework MVP

[quoted text, click to view]

Tim Wilson
7/29/2005 1:50:19 PM
There's also an article, done by the same person that did the webcast,
starting at the link below. The article is similar to the webcast in terms
of what is covered.
http://symbian.sys-con.com/read/113332_1.htm

--
Tim Wilson
..Net Compact Framework MVP

[quoted text, click to view]

notu
8/1/2005 9:27:56 AM
The web cast and link show how to create a 'User" type custom control not a
custom control that inherits from control class or a specific class like
panel. I need to create a non-user type control that can be added to the
toolbox. I have done this in VS 2003 the control can be dragged onto forms
from the toolbox. So what I need is to know how to get my custom controls
that I created in VS 2003 to appear on the toolbox in VS 2005.



Any further help would be great.



Thanks again.



[quoted text, click to view]

Tim Wilson
8/1/2005 11:06:53 AM
You have to migrate. I don't think that there are any resources out there
yet to explain this process. I would just create a new control library
project, add your existing code, and compile. If you add an application
project to the same solution, then once you compile your control (whether it
inherits from Control or UserControl) it should appear at the top of the
ToolBox. Then just drag and drop. Of course, it may not be this simple... it
really depends on how extensive your custom control is.

--
Tim Wilson
..Net Compact Framework MVP

[quoted text, click to view]

notu
8/1/2005 12:01:34 PM
Well that worked better than expected. I had to change my class to a partial
class. The only real error i got was...



Error 1 'My.CustomControls.MyGrid' does not contain a definition for
'AutoScaleMode'



*MyGrid.Designer.cs has ...

private void InitializeComponent()

{

components = new System.ComponentModel.Container();

this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;

}

I suspect that AutoScaleMode is a property of the user UserControl class
and that the error occurs because I inherit from the controls class.

I can remark out the autoscalemode line and it compiles.

Is this acceptable of should I be using AutoScaleMode with my non user type
custom control?



Thanks

[quoted text, click to view]

Tim Wilson
8/1/2005 1:52:33 PM
[quoted text, click to view]
Yes. I forgot to mention that. This is usually one of the first things that
I do after creating a control library project (if I'm not planning on using
the UserControl)... refactor the name, change to inherit from Control (or
another class), and just delete (off the top of my head)
UserControl1.Designer.cs (you will need to show all files to see this file)
since (again, off the top of my head) it only contains the
InitializeComponent method, which is usually not used when you're inheriting
from Control since this is really more of a designer-related method.

[quoted text, click to view]
Just delete that line, or the file as I mentioned above. As the compiler
indicated, it's not available to you since it's introduced with the
ContainerControl class, which the UserControl class inherits from.

--
Tim Wilson
..Net Compact Framework MVP

[quoted text, click to view]

Genifer
8/3/2005 12:39:55 PM
Thanks Tim! Very appreciated!

Is any of the following also needed with an authored control vs. a user
control?

// private System.ComponentModel.IContainer components = null;

// /// <summary>
// /// Clean up any resources being used.
// /// </summary>
// /// <param name="disposing">true if managed resources should be
disposed; otherwise, false.</param>
// protected override void Dispose(bool disposing)
// {



[quoted text, click to view]

Tim Wilson
8/3/2005 2:07:11 PM
The "components" stuff, no. You won't need that. However, you should
implement the dispose pattern if you're using unmanaged resources or, in
general, feel that the end-developer needs to explicitly dispose of other
managed resources that are internal to your custom control. So the "Dispose"
method *may* be relevant to you. This pattern should pretty much already
been implemented on the existing controls, so you may just be able to take
advantage of it if necessary.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconfinalizedispose.asp

--
Tim Wilson
..Net Compact Framework MVP

[quoted text, click to view]
AddThis Social Bookmark Button