473,405 Members | 2,379 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,405 software developers and data experts.

usercontrol

hi all

why should I use a usercontrol for ?
does it have some advantages?

thanks Maarten
Jul 17 '05 #1
3 4129
On Sat, 6 Nov 2004 16:05:50 +0100, "Maarten" <gu******@hotmail.com>
wrote:
hi all

why should I use a usercontrol for ?
Most things graphical, and some things non graphical
does it have some advantages?
Yes
thanks Maarten


Best try writing one, they are very easy.
Jul 17 '05 #2

"Maarten" <gu******@hotmail.com> wrote in message
news:41**********************@news.skynet.be...
| hi all
|
| why should I use a usercontrol for ?
| does it have some advantages?
|
| thanks Maarten
|

A good way to start is to make a user control that contains one regular
control, so you can define some special behavior for it. Try this in a
new project:

1. Click on Project menu, Add User Control
2. On the user control, place one text box.
3. Add the code below. Close the user control window.
4. On Form1, place 2 or 3 of your new controls. Your control will appear
last on the toolbox, and you can place them just like other controls.
5. Run the program, and type stuff in the text boxes.
6. Note that you can now use this control as many times as you like on
different forms, without having to duplicate the color change code.

' User control code

Private Sub Text1_Change()
If InStr(1, Text1.Text, "red", vbTextCompare) Then
Text1.ForeColor = vbRed
Else
Text1.ForeColor = vbBlack
End If
End Sub

Private Sub UserControl_Resize()
With UserControl
Text1.Move .ScaleLeft, .ScaleTop, .ScaleWidth, .ScaleHeight
End With
End Sub
Jul 17 '05 #3
I think of a UC as a class with window properties.
It's a great way to encapsulate API functions for
another control or to use owner-drawn windows.
Owner drawn windows are a pain in VB because
they don't show up in the IDE. But if you associate an
owner-drawn window with a UC you can tie things
like Top, Left, Width, Height to the UC for easy
GUI management of the window and you can also
place the window on a form at "design time".
So you might say it's a blank slate with all the
conveniences of a VB component (visibility in
the IDE, hWnd, dimensions, etc.).
_____________________________

ma**********@mindYYspring.com
For return email remove XX and YY.
_____________________________
Maarten <gu******@hotmail.com> wrote in message
news:41**********************@news.skynet.be...
hi all

why should I use a usercontrol for ?
does it have some advantages?

thanks Maarten

Jul 17 '05 #4

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

Similar topics

2
by: Dave Veeneman | last post by:
Is there a simple way to pass drag-and-drop events to a child control in a UserControl? Here's an example: I have created a UserControl which contains a treeview and some text boxes. I want to...
8
by: Raed Sawalha | last post by:
Hi, I have a strange problem with a usercontrol on a page. The usercontrol dispalyes three categories (From a database) when the user clicks a category they see all the products in a shop for...
2
by: Eric Maia | last post by:
I have two UserControls I am using in a form. These are each also used separately in two other forms. The structure is essentially this: CourseUserControl.ascx - select or enter a course...
2
by: Sascha | last post by:
Hi there, I searched carefully through the web before finally deciding to post this message, because I could not find a solution for my problem. Hopefully someone will have a hint or explanation...
41
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based...
12
by: Joe | last post by:
Hello All: Do I have to use the LoadControl method of the Page to load a UserControl? I have a class which contains three methods (one public and two private). The class acts as a control...
9
by: Marcelo Cabrera | last post by:
Hi, I have a user control that in turn creates a bunch of webcontrols dynamically and handles the events these webcontrols raise. It used to work fine on ASP .Net 1.1 but when compiled on 2.0 it...
5
by: Blue | last post by:
We have a custom word processing type editor built with C# and .NET 2.0 and we need to support typing in languages other than English. I want to be able to use the Windows IME to enter in text...
6
by: MeowCow | last post by:
I have created a UserControl that encapsulates a third party data grid. My goal was to create my own DataSource and DataMember properties that forward the binding to the third party grid, then use...
10
by: Benton | last post by:
Hi there, I have a UserControl with a couple of textboxes and a couple of buttons ("Save" and "Cancel"). The Click event for this buttons is in the UserControl's codebehind of course, so here's...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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...
0
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...
0
agi2029
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,...
0
isladogs
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...

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.