473,395 Members | 1,676 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,395 software developers and data experts.

How to create user control with multiple controls?

Hi, All,
I want to create a single user control (component) with
multi-controls. for example, I want to use one button
control and 2 listBox controls to build one single user
control. so, user can directely use the user control
instead of 3 controls. They can click button to move the
selected item from one listbox to another. but how can I
inherit these 3 controls? And also, once I create the
single user control, I can not implement the methods or
events like "Click" by cliking the button, because all
the 3 controls are integrate to a single unit once user
try to use it. I didn't find any example using google.

Any suggestion?
Thanks and have a one

Brian
Nov 21 '05 #1
3 6727
"Brian" <an*******@discussions.microsoft.com> schrieb:
I want to create a single user control (component) with
multi-controls. for example, I want to use one button
control and 2 listBox controls to build one single user
control. so, user can directely use the user control
instead of 3 controls. They can click button to move the
selected item from one listbox to another. but how can I
inherit these 3 controls?
Simply choose "Project" -> "Add usercontrol...". In the designer, place the
controls on the usercontrol.
And also, once I create the single user control, I can
not implement the methods or events like "Click" by
cliking the button, because all the 3 controls are integrate
to a single unit once user try to use it.


Add handlers to the relevant events of all controls on the usercontrol and
call the appropriate 'MyBase.On<event name>' method of the usercontrol to
raise the event as an event of the usercontrol.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #2
Herfried,
Thanks for your help, but I still have a few questions.
First, In my user control, it should be "Inherits
System.Windows.Forms.UserControl" or something else?

Second, If I have a click event like,Public Overridable
Sub cmdAssign_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles cmdAssign.Click on user
control. How can I call the myBase.onCmdAssign_Click( the
one you tell me 'MyBase.On<event name>' method ) when I
implement?

I'm new to .Net, could you give me more detail?

Thanks lot and really appreciate your help

Brian
Add handlers to the relevant events of all controls on the usercontrol andcall the appropriate 'MyBase.On<event name>' method of the usercontrol toraise the event as an event of the usercontrol.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

.

Nov 21 '05 #3
Brian,

"Brian" <an*******@discussions.microsoft.com> schrieb:
First, In my user control, it should be "Inherits
System.Windows.Forms.UserControl" or something else?
Yes, you should inherit from 'UserControl', otherwise you won't be able to
create a composite control in the designer.
Second, If I have a click event like,Public Overridable
Sub cmdAssign_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles cmdAssign.Click on user
control. How can I call the myBase.onCmdAssign_Click( the
one you tell me 'MyBase.On<event name>' method ) when I
implement?


Call 'MyBase.OnClick(...)' in all controls' 'Click' event handlers in order
to raise a single click event for the whole usercontrol if any of the
controls is clicked.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #4

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

Similar topics

3
by: Varad | last post by:
Hi all Pls give me some insight as to what I should be doing. I have a form where I have 20 text boxes and when an user submits the form I save it to a database. When they want to retrieve it, I...
4
by: BBFrost | last post by:
We have a data entry application written within Framework 1.0 that contains 20+ custom user controls. The controls overlay each other so that only one custom control is visible at a time. What...
1
by: David J. Berman | last post by:
Thanks for any help...! My error is: Object reference not set to an instance of an object. > public int DisplayOrder { > get { >>>>>> return (int) ViewState; > }
5
by: Jonah Olsson | last post by:
Hello guys, I have an application which is built upon several user controls. That is, I have a default template (default.aspx) that I load a user control into (using placeholders in the...
3
by: JohnR | last post by:
I have a form with a number of text boxes, comboboxes etc. What I would like to do is create an event handler for the "mouseenter" event for each of the controls whereby I display information...
9
by: Gummy | last post by:
Hello, I created a user control that has a ListBox and a RadioButtonList (and other stuff). The idea is that I put the user control on the ASPX page multiple times and each user control will...
1
by: Dave A | last post by:
I have a problem that I have boiled down to a very simple example. I have a user control that displays a some data from a business object. On one screen I have a collection of these business...
1
by: zb | last post by:
Here is the page architecture: Page loads multiple user controls (including nested user controls) dynamically based on parameters provided into place holders. Note: The page only has the logic to...
1
by: zeya_bakhtyar | last post by:
Here is the page architecture: Page loads multiple user controls (including nested user controls) dynamically based on parameters provided into place holders. Note: The page only has the logic to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
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.