I'm a little new to the C# way of doing thisgs... Although
I've done this sort of thing before in VS 6 / MFC...
creatnig controls, ActiveX controls, etc. Creating
controls in MFC is pretty straightforward and dare I say
intuitive? (well, as intuitive as you can get w/ MFC.)
Anyhow, I am wanting to create some controls of my own w/
C#. I'm not quite sure where to start though. I created
a Windows Control library project, and I get
a "Usercontrol1.c s" file / designer, now what? I tried
changing the class to inherit from a Textbox insted of a
UserControl, and my designer wouldnt' render the image
anymore, althuogh a text box did show up in my test
container, but now I'm a little stuck...
With MFC, I had a source listing of the base class so I
could tell what things I needed to override. I don't have
that in C#, and some of the functions (like OnDraw())
dont' seem to be the same, so I don't knwo where to go
from here.
What I want to create, for now at least, is just a simple
text box control for entering an IP address. I have
another post out abuot this subject, abuot the IP adderss
control that is already in Windows (somewhere) but in this
case, I want to create the control just for the practice
of doing it in C#. I am trying to get up to speed on this
now that I'll be working with it. Thanks!
JIM 2 1794
Jim,
For what you are doing, you want to derive from TextBox, as you
suspected. When you have a custom control project (or rather, add a custom
control), it assumes you want a composite control with other controls on it,
so it automatically derives from UserControl.
However, if you are looking to create a base control, then you can not
do this obviously. Deriving from TextBox is the right thing, but as you
have found, you don't get designer support. Of course, you probably don't
need it either at this point.
The Control base class has a number of overrides. Check out the MSDN
documentation, and look at the protected members specifically. These are
the ones that are overridden to give your control the functionality you
want.
Specifically, you will want to look at the following properties/methods:
OnPaint
CreateParams
WndProc
Hopet his helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Jim" <an*******@disc ussions.microso ft.com> wrote in message
news:0d******** *************** *****@phx.gbl.. . I'm a little new to the C# way of doing thisgs... Although I've done this sort of thing before in VS 6 / MFC... creatnig controls, ActiveX controls, etc. Creating controls in MFC is pretty straightforward and dare I say intuitive? (well, as intuitive as you can get w/ MFC.)
Anyhow, I am wanting to create some controls of my own w/ C#. I'm not quite sure where to start though. I created a Windows Control library project, and I get a "Usercontrol1.c s" file / designer, now what? I tried changing the class to inherit from a Textbox insted of a UserControl, and my designer wouldnt' render the image anymore, althuogh a text box did show up in my test container, but now I'm a little stuck...
With MFC, I had a source listing of the base class so I could tell what things I needed to override. I don't have that in C#, and some of the functions (like OnDraw()) dont' seem to be the same, so I don't knwo where to go from here.
What I want to create, for now at least, is just a simple text box control for entering an IP address. I have another post out abuot this subject, abuot the IP adderss control that is already in Windows (somewhere) but in this case, I want to create the control just for the practice of doing it in C#. I am trying to get up to speed on this now that I'll be working with it. Thanks!
JIM
Thanks... I appreciate the info there. I hope that gets
me going ni the right direction.... I take it then that I
can remove the stuff from my class that the designer puts
in there? (the #region that says it's for the designer)
or should I just leave all that alone?
I was given to understand that migrating to C# from C++
wasn't going to be that big of a deal, but the more I see
of it, the moer I'm starting to wonder if MS just didn't
re-invent the wheel... It's a fine platform, and I'm too
new to pass judgement on it, it just seems that some
things that were once easy and intuitive have now become
obscure and in some cases (like the original IP control
from Windows) are outright absent from this new platform.
Perhaps though I am missing something-- It was / is my
understanding that .NET is supposed to replace the
previous VS / MFC way of diong things?
Years ago (liek 1991... LOL) I bought a great little
paperback called "Moving from C to C++" that gave me a
nice hands-on transition from procedural C language to the
object-orietned world of C++ (or at least as OO as you
could get before Windows... LOL) Are there any good,
concise resources on teh migration from C++ to C#, or C#
just a whole nwe ball of wax? I don't need to learn how
to program all over again, just need to learn to do the
things I already know how to do, but learn to do them ni
C#, and a basic understanding of the way apps and
components are put together in C# as opposed, for example
to C++. It all seems to be substantially different than
from what I expected, the more that i look at it. Thanks.
JIM -----Original Message----- Jim,
For what you are doing, you want to derive from
TextBox, as yoususpected. When you have a custom control project (or
rather, add a customcontrol), it assumes you want a composite control with
other controls on it,so it automatically derives from UserControl.
However, if you are looking to create a base control,
then you can notdo this obviously. Deriving from TextBox is the right
thing, but as youhave found, you don't get designer support. Of course,
you probably don'tneed it either at this point.
The Control base class has a number of overrides.
Check out the MSDNdocumentatio n, and look at the protected members
specifically. These arethe ones that are overridden to give your control the
functionality youwant.
Specifically, you will want to look at the following
properties/methods: OnPaint CreateParams WndProc
Hopet his helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"Jim" <an*******@disc ussions.microso ft.com> wrote in
messagenews:0d******* *************** ******@phx.gbl. .. I'm a little new to the C# way of doing thisgs...
Although I've done this sort of thing before in VS 6 / MFC... creatnig controls, ActiveX controls, etc. Creating controls in MFC is pretty straightforward and dare I say intuitive? (well, as intuitive as you can get w/ MFC.)
Anyhow, I am wanting to create some controls of my own
w/ C#. I'm not quite sure where to start though. I
created a Windows Control library project, and I get a "Usercontrol1.c s" file / designer, now what? I tried changing the class to inherit from a Textbox insted of a UserControl, and my designer wouldnt' render the image anymore, althuogh a text box did show up in my test container, but now I'm a little stuck...
With MFC, I had a source listing of the base class so I could tell what things I needed to override. I don't
have that in C#, and some of the functions (like OnDraw()) dont' seem to be the same, so I don't knwo where to go from here.
What I want to create, for now at least, is just a
simple text box control for entering an IP address. I have another post out abuot this subject, abuot the IP
adderss control that is already in Windows (somewhere) but in
this case, I want to create the control just for the practice of doing it in C#. I am trying to get up to speed on
this now that I'll be working with it. Thanks!
JIM
. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Altramagnus |
last post by:
I have 30 - 40 type of different window.
For each type I need about 20 instances of the window.
When I try to create them, I get "Error creating window handle"
My guess is there is a maximum number of window handle, because if I reduce
to about 2 instances of each window,
it can run. But not 20 instances of each window.
Does anyone know what the problem is? is it really because it exceeds the
maximum number of window handle?
|
by: Jai |
last post by:
Dear All
Creating Custom Controls but Not User Controls,How to create custom
controls,i.e
Extending the functionality of the Existing Controls.(Web Custom Controls).
Previously i have submitted the same Query but i got replay for user
controls,but my requirement is not that one.My requirement is Custom web
controls.
|
by: Ken Varn |
last post by:
I am just starting the process of creating ASP.NET server controls. I have
created controls for .NET applications, but have just started with ASP.NET.
I am a little confused about some areas that I am hoping someone can help
clear up.
1. What is the difference between initializing a control in the
constructor, vs the OnInit(), vs the CreateChildControls() methods?
2. The control that I created contains an Items collection attribute...
|
by: Patrick |
last post by:
I want to define a set of web-form templates in XML and render the equivalent
web-form with ASP.NET, then process any input server controls on the form.
Reading the XML file from Page_load is easy, but
1) How do I set about dynamically creating user controls (like TextBox,
TextArea)
--- simply Declare and initialised (new) the user controls?? How do I
"place" it graphically on the form. Ideally, I want them to lay out in a
table, one...
|
by: Mats Lycken |
last post by:
Hi,
I'm creating a CMS that I would like to be plug-in based with different
plugins handling different kinds of content.
What I really want is to be able to load/unload plugins on the fly
without restarting the application.
What I did was to create an AppDomain that loaded the plugins and
everything was great, until I tried to pass something else that strings
between the domains...
| |
by: Varangian |
last post by:
Hello
is creating controls at runtime the same as designtime ?
will a page be faster if controls are created at designtime rather than
at runtime ? If so why ?
thanks :)
|
by: SalamElias |
last post by:
I am creating several chkBoxes dynamically and assigning an event handler in
the Page_load as foillows
*****************************
Dim chkCatOption As CheckBox = New CheckBox
chkCatOption.Text = rowDS.Item("Option_Item_Desc")
chkCatOption.ID = rowDS.Item("ID").ToString
chkCatOption.Checked = rowDS.Item("HasOption")
chkCatOption.AutoPostBack = True
AddHandler chkCatOption.CheckedChanged, AddressOf
AddOrUpdate
|
by: Tarscher |
last post by:
hi all,
I have this seemingly simple problem. I have lost a lot of time on it
though.
When a user selects a value from a dropdownlist (static control) a
dynamic control is generated. I have to create the dynamic controls
in the OnInit stage of the lifecycle. Since data from static controls
is not yet available in the OnInit stage I can't know what dynamic
control I have to create.
|
by: Abdo Haji-Ali |
last post by:
Previously I used to create user controls if I wanted to use a
specific set of controls in multiple pages, however I want to deploy
my control in other applications so I thought of creating custom
controls.
Only problem is that I'm used to designing my controls in a WYSIWYG
(tm) way (i.e. using the designer and writing HTML tags). The only way
I found to create custom controls was to create controls dynamically,
set their properties and...
|
by: mohaaron |
last post by:
I can think of a lot of reasons why this might need to be done but as
far as I can tell it's not possible. I've been looking for a way to
add HtmlTableRows to a table using a button click for a while and it
seems it's not possible because the row that gets added with each
click won't get recreated after a post back. After all the reading it
seems that any dynamically created controls must be created in the
Init event to be recreated after...
|
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,...
| |
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...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |