toolbox ready CF custom controls for VS 2005?

N

notu

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
;)
 
T

Tim Wilson

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/W...&EventCategory=5&culture=en-US&CountryCode=US
 
N

notu

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.
 
T

Tim Wilson

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.
 
N

notu

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
 
T

Tim Wilson

I suspect that AutoScaleMode is a property of the user
UserControl class and that the error occurs because I
inherit from the controls class.
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.
Is this acceptable of should I be using AutoScaleMode
with my non user type custom control?
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.
 
G

Genifer

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)
// {
 
T

Tim Wilson

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/d.../en-us/cpgenref/html/cpconfinalizedispose.asp
 

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