473,386 Members | 1,973 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

(HW) Adding custom controls within a project

Hi,

I have created a custom textBox within a C# project. I want to put that
custom textBox on a form now. I heard about a way, to place that user
control onto a form within the same project, without having to compile it
seperately before.

An example:

1. In Visual Studio create a new C# Windows Application
2. Add a User Control to the Project
3. Modify the code of the control so that it inherits from
System.Windows.Forms.TextBox
4. Overwrite some function (i. e. OnDragEnter)

protected override void OnDragEnter(DragEventArgs drgevent)
{
MessageBox.Show("Test");
base.OnDragEnter (drgevent);
}

5. ...and this is where I stuck: Add this modified textBox to the existing
Form1

It's not possible, to simply drag it on the Form (in Design View), like you
do with controls from the Toolbox. I know, that there's a way. I saw this a
couple of months before in some presentation, but cannot remember how the
guy did this.

Anybody out there knows?
Nov 16 '05 #1
3 3250
The common way
Right Click the Toolbox and select "Add/Remove Items..."
Browse to your projects Bin directory and select the exe.
Click the OK button and the control will be added to the toolbox.
This will be on the toolbox of every project you now open.

The way I do it
Comment out the code for your control.
Change Inheritance from TextBox to UserControl.
Show the controls designer and rebuild the project.
The textbox control is now in your "My User Controls" tab.
Reset inheritance back to TextBox, uncomment the code and rebuild.
This will only be on the toolbox for your current project.

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Helmut Wagensonner" <he****************@gmx.net> wrote in message
news:eQ**************@TK2MSFTNGP14.phx.gbl...
Hi,

I have created a custom textBox within a C# project. I want to put that
custom textBox on a form now. I heard about a way, to place that user
control onto a form within the same project, without having to compile it
seperately before.

An example:

1. In Visual Studio create a new C# Windows Application
2. Add a User Control to the Project
3. Modify the code of the control so that it inherits from
System.Windows.Forms.TextBox
4. Overwrite some function (i. e. OnDragEnter)

protected override void OnDragEnter(DragEventArgs drgevent)
{
MessageBox.Show("Test");
base.OnDragEnter (drgevent);
}

5. ...and this is where I stuck: Add this modified textBox to the existing
Form1

It's not possible, to simply drag it on the Form (in Design View), like
you do with controls from the Toolbox. I know, that there's a way. I saw
this a couple of months before in some presentation, but cannot remember
how the guy did this.

Anybody out there knows?

Nov 16 '05 #2
Thanks a lot! I will try immediately. I remember, that the guy in the
presentation used a different way - but anyway...

Thx, Helmut
"Mick Doherty"
<EX***********@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com]> schrieb
im Newsbeitrag news:eh*************@tk2msftngp13.phx.gbl...
The common way
Right Click the Toolbox and select "Add/Remove Items..."
Browse to your projects Bin directory and select the exe.
Click the OK button and the control will be added to the toolbox.
This will be on the toolbox of every project you now open.

The way I do it
Comment out the code for your control.
Change Inheritance from TextBox to UserControl.
Show the controls designer and rebuild the project.
The textbox control is now in your "My User Controls" tab.
Reset inheritance back to TextBox, uncomment the code and rebuild.
This will only be on the toolbox for your current project.

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Helmut Wagensonner" <he****************@gmx.net> wrote in message
news:eQ**************@TK2MSFTNGP14.phx.gbl...
Hi,

I have created a custom textBox within a C# project. I want to put that
custom textBox on a form now. I heard about a way, to place that user
control onto a form within the same project, without having to compile
it seperately before.

An example:

1. In Visual Studio create a new C# Windows Application
2. Add a User Control to the Project
3. Modify the code of the control so that it inherits from
System.Windows.Forms.TextBox
4. Overwrite some function (i. e. OnDragEnter)

protected override void OnDragEnter(DragEventArgs drgevent)
{
MessageBox.Show("Test");
base.OnDragEnter (drgevent);
}

5. ...and this is where I stuck: Add this modified textBox to the
existing Form1

It's not possible, to simply drag it on the Form (in Design View), like
you do with controls from the Toolbox. I know, that there's a way. I saw
this a couple of months before in some presentation, but cannot remember
how the guy did this.

Anybody out there knows?


Nov 16 '05 #3
There is a My UserControls group in the toolbox that will show
UserControl-derived classes that were added in VS.NET to a referenced
project. They do sometimes appear in other circumstances, but I never
figured out why.

So, add Project1, add Project2, Reference Project1 in Project2, add a
UserControl to Project1, switch to Project2, and it should appear in the
MyUserControls group.

"Helmut Wagensonner" <he****************@gmx.net> wrote in message
news:eQ**************@TK2MSFTNGP14.phx.gbl...
Hi,

I have created a custom textBox within a C# project. I want to put that
custom textBox on a form now. I heard about a way, to place that user
control onto a form within the same project, without having to compile it
seperately before.

An example:

1. In Visual Studio create a new C# Windows Application
2. Add a User Control to the Project
3. Modify the code of the control so that it inherits from
System.Windows.Forms.TextBox
4. Overwrite some function (i. e. OnDragEnter)

protected override void OnDragEnter(DragEventArgs drgevent)
{
MessageBox.Show("Test");
base.OnDragEnter (drgevent);
}

5. ...and this is where I stuck: Add this modified textBox to the existing
Form1

It's not possible, to simply drag it on the Form (in Design View), like
you do with controls from the Toolbox. I know, that there's a way. I saw
this a couple of months before in some presentation, but cannot remember
how the guy did this.

Anybody out there knows?

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Paul Dunstone | last post by:
Hi group I am trying to add a custom attribute to all .NET elements such as textboxes, labels, datagrids etc. I want to add an attribute called 'key'. I already have the code working for the...
2
by: avivgur | last post by:
Hello, I am writing a program in Visual C# and I have encountered a problem. In my program I want to dynamically create a multitude of controls (thousands) on a form. The problem is that calling...
3
by: Michael | last post by:
Hi all.. I have a solution containing 5 projects, one of which is a custom control. In one of the projects, I dragged the .ascx file from the custom control project and dropped it onto a form....
3
by: Kannan | last post by:
Hi, I am trying to created Outloook Add-in Com in outlook using C#. I have seen this URL for developing this sample http://support.microsoft.com/?kbid=302901 When I executed this program it...
3
by: Jonathan Wood | last post by:
I could really use some help on this. First of all, I want to create a Web control where I render the control completely from scratch based on information from a database. In the book...
6
by: | last post by:
I have made some user controls with custom properties. I can set those properties on instances of my user controls, and I have programmed my user control to do useful visual things in response to...
11
by: Nick Gilbert | last post by:
Hi, How can I create a custom control which will wrap its content in a header and footer? eg: Is it possible to create a .NET user control which can surround other controls? eg:...
7
by: Linda Liu[MSFT] | last post by:
Hi George, I have downloaded your sample solution and built it on my machine. I got a compilation error indicating that the type of "CustomResources" doesn't exist in the following xaml code: ...
2
by: Ken Fine | last post by:
I want to add the security question and answer security feature to the ChangePassword control. I am aware that this functionality is built into the PasswordRecovery tool. I have implemented the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.