473,768 Members | 1,513 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

(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(Dra gEventArgs drgevent)
{
MessageBox.Show ("Test");
base.OnDragEnte r (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 3272
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******** ******@TK2MSFTN GP14.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(Dra gEventArgs drgevent)
{
MessageBox.Show ("Test");
base.OnDragEnte r (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.SQUA REBRACKETS.[mdaudi100#ntlwo rld.com]> schrieb
im Newsbeitrag news:eh******** *****@tk2msftng p13.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******** ******@TK2MSFTN GP14.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(Dra gEventArgs drgevent)
{
MessageBox.Show ("Test");
base.OnDragEnte r (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******** ******@TK2MSFTN GP14.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(Dra gEventArgs drgevent)
{
MessageBox.Show ("Test");
base.OnDragEnte r (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
1651
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 key attribute (it is used to localise text within the element) but .NET reports that the attribute is not valid. Although the code works I would prefer not to get the warning each time myself or one of the other coders use the key attribute. Is
2
3733
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 the Controls.Add() method several times or even calling the Controls.AddRange() method once can take a huge amount of time. Therefore, I would like to be able to run the loop that creates the controls on a different thread and meanwhile give the user...
3
1719
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. I've also referenced the custom control project. Everything looks good, I can see properties and events, etc. The solution builds with no errors. The folder structure loks like this. The folder Fleet is the top level solution with sub folders...
3
1996
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 created new custom button called "My Custom Button" in the Outlook menu bar. But when I tried to create one more button called "Forward Mail" (code is
3
1883
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 "Beginning ASP.NET 2.0 in C# 2005", it provides an example of doing this, which is declared as: public class ConfigurableRepeater : WebControl.
6
11081
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 how those properties are set. I want to be able to do two other things: a) add User control instances to my page, filling in the place of placeholder controls, and b) programmatically setting custom properties on those dynamically spawned...
11
3287
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: <my:RoundedCornerBox id=foo runat=server>
7
10916
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: <Expander Style="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type res:CustomResources}, ResourceId=CustomExpanderStyle1}}" >
2
7667
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 PasswordRecovery with a Password reset required; a temporary password is sent to the account on file. I want an extra layer of security to accommodate the very unlikely contingency that someone's e-mail account is compromised. Challenging with the...
0
9575
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9407
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10171
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10015
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9842
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6656
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3931
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3534
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2808
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.