Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Just to make sure I am doing it right
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00984198
Message ID:
00984206
Views:
22
Einar,

Here's what I did when I created my set of subclassed winform controls. I have a separate project called cgsControls.

1) Create a new project as a class library. I called mine cgsControls
2) I renamed the new Class1.Cs to cgsControls.Cs
3) I add a reference in the new project to System.Windows.Forms and System.Drawing
4) In CgsControls.cs, I use the following to subclass the label and textbox control
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

namespace cgsControls
{
	public class cgsLabel: System.Windows.Forms.Label
	{
		override public Font Font 
		{ 
			get { return base.Font; } 
			set { ; } 
		}  

		public cgsLabel()
		{
			base.Font = new  Font("Verdana",8);
		}
	}

	public class cgsTextBox: System.Windows.Forms.TextBox
	{
		override public Font Font 
		{ 
			get { return base.Font; } 
			set { ; } 
		}  

		public cgsLabel()
		{
			base.Font = new  Font("Verdana",8);
		}
	}

}
You may want to add all your subclass definitions in here (datetime picker, command button, combox box, etc.)

5) I build the project DLL.

6) Then, I start a new winform project. In order to see the text and label classes in my toolbox (so that I can drop them on a form), I go to my toolbox, right-click, take "Add/remove items", and then browse for the cgsControls.DLL in the BIN/DEBUG folder of the location where I saved my cgsControls project. (Before you take add/remove items, you may wish to add a brand new tab first, specificallly for your subclassed controls).

Hopefully that should get you started. You only need to use "usercontrol" if what you're actually building is a usercontrol (collection of your subclasseed controls...VFP's equivalent to a container). Let me know if that helps.

Kevin
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform