473,772 Members | 2,442 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to pass Composite Control messages to the parent Form?

Hello,

I developed a Composite Control with Visual C# (Rocker Button). The button
detects MouseUp events inside the control. However I would like these
MouseUp events to be transferred to the parent form of this control so I can
update the form with the new information.

The messages are trapped inside the control but are not seen by the parent
form.

Any idea how to do that?

EitnaB
Nov 20 '07 #1
4 3198
On 2007-11-20 14:55:02 -0800, Eitan <Ei***@discussi ons.microsoft.c omsaid:
Hello,

I developed a Composite Control with Visual C# (Rocker Button). The button
detects MouseUp events inside the control. However I would like these
MouseUp events to be transferred to the parent form of this control so I can
update the form with the new information.

The messages are trapped inside the control but are not seen by the parent
form.

Any idea how to do that?
While it would be possible to do that, it seems to me that you would
rather use an event to signal the change in the state of the control,
or to react to a specific state.

For example, there's the Control.Click event, which something like a
Button control will use to signal that the button has actually been
successfully depressed and released.

Or you could go the data-centric route. For example, the
Control.TextCha nged event will signal when the Text property has
changed.

For a "rocker button", I would think you would expose a single state as
a property (perhaps using an enumeration). If the property is named
RockerState, then you might have a RockerStateChan ged event that the
parent form or any other code could subscribe to, for the purpose of
learning when the state of the rocker switch has changed.

Alternatively, you could have events corresponding to each position the
rocker button could have, with each event being raised as the rocker
changes position. I would prefer the previous idea, but this would
work too.

For me, the mouse events are more for use by the control itself to
handle interactions with the user. Higher-level control and signaling
should be implemented with a higher-level paradigm.

Pete

Nov 20 '07 #2
Hi,

did you try KeyPreview in the Parent Form?
Otherwise you can use SendMessage API
to transfer the messages to the upper level
parent control. You can subclass the parent
control or the child control and route the messages
in booth directions using SendMessage API
from Windows API,...

Hope this helps,...
Regards

Kerem
--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
ke*****@arcor.d e

Best Quote: "Ain't nobody a badass with a double dose
of rock salt...", Kill Bill Vol.2

Microsoft Live Space: http://kerem-g.spaces.live.com/
Latest Open-Source Projects: http://entwicklung.junetz.de
Sign my guestbook: http://entwicklung.junetz.de/guestbook/
-----------------------
"This reply is provided as is, without warranty express or implied."
Nov 20 '07 #3
Hello Pete,

My problem is how to expose RockerStateChan ged event (for example) like you
suggested. I did expose properties with no problem but having difficulty to
send events to the hosting form.

Thanks
EitanB

"Peter Duniho" wrote:
On 2007-11-20 14:55:02 -0800, Eitan <Ei***@discussi ons.microsoft.c omsaid:
Hello,

I developed a Composite Control with Visual C# (Rocker Button). The button
detects MouseUp events inside the control. However I would like these
MouseUp events to be transferred to the parent form of this control so I can
update the form with the new information.

The messages are trapped inside the control but are not seen by the parent
form.

Any idea how to do that?

While it would be possible to do that, it seems to me that you would
rather use an event to signal the change in the state of the control,
or to react to a specific state.

For example, there's the Control.Click event, which something like a
Button control will use to signal that the button has actually been
successfully depressed and released.

Or you could go the data-centric route. For example, the
Control.TextCha nged event will signal when the Text property has
changed.

For a "rocker button", I would think you would expose a single state as
a property (perhaps using an enumeration). If the property is named
RockerState, then you might have a RockerStateChan ged event that the
parent form or any other code could subscribe to, for the purpose of
learning when the state of the rocker switch has changed.

Alternatively, you could have events corresponding to each position the
rocker button could have, with each event being raised as the rocker
changes position. I would prefer the previous idea, but this would
work too.

For me, the mouse events are more for use by the control itself to
handle interactions with the user. Higher-level control and signaling
should be implemented with a higher-level paradigm.

Pete

Nov 21 '07 #4
On 2007-11-21 06:58:02 -0800, Eitan <Ei***@discussi ons.microsoft.c omsaid:
My problem is how to expose RockerStateChan ged event (for example) like you
suggested. I did expose properties with no problem but having difficulty to
send events to the hosting form.
Well, what did you try? What didn't work?

Pete

Nov 21 '07 #5

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

Similar topics

5
6929
by: John | last post by:
Specifically for joint tables... tblStudents tblClasses tblClasses_Students Is it be good programming to use a composite primary key in tblClasses_Students (where the key is ClassID and StudentID)? I enventually will convert the Access db to an SQL db. I've always used single primary keys based on long integers, usually autonumbered.
2
5202
by: fragget | last post by:
hi- i have a custom control that can be dragged onto a form. the control can be dragged around the form with the mouse. i want to draw a selection box around my control when it is selected to be dragged. on the mouse down event of my control i want to pass the size of the control and the location to the parent so that i can draw a selection box around it.
11
6200
by: Sagaert Johan | last post by:
I have made a custom control that draws a rectangle when the mouse is down, and does nothing when the mouse is up. I set/reset a flag in MouseDown/Mouse up and use this to do the drawing in the OnPaint . The recangle draws correct when i press the mouse, but when i release the mouse the background is not restored What should i do in the Onpaint to make sure the background (the form) is restored correctly ? This problem already keeps...
5
4091
by: Barry Carr | last post by:
Hi, I've created a composite custom web control and a ControlDesigner descendant to render the control a design time. The child controls are public properties of composite control and as such the child controls appear in the property inspector as sub-properties of the main control and can be manipulated as normal at design time. If any of the properties of the parent (main) control are changed at design time the composite control is...
10
2324
by: dx | last post by:
I have the Microsoft Press: Developing Microsoft ASP.NET Server Controls and Components book. It's starting to shine some light on control development but there is something about composite controls that I don't understand... I've included a snippet from Chapter 12 below on Composite Controls: <start> Override the CreateChildControls method to instantiate child controls, initialize them, and add them to the control tree. Do not perform...
6
2633
by: shapper | last post by:
Hello, I am working in a class library with various custom controls. In which cases should a control inherit Control, WebControl and CompositeControl classes? And when should a custom control implement INamingContainer? In this moment I am working on a custom control that is composed by a
1
2036
by: berny.zamora | last post by:
Hello everyone, I have a composite control (lets call it the parent) that contains a datalist. The datalist has an ItemTemplate that contains another composite control (lets call it the child). I am trying to create a property at the parent control that sets a property in the child instances. So for example lets say I am creating a control that displays a list of hotel reservations for a group of people.
12
11110
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms. Here is a newbie mistake that I found myself doing (as a newbie), and that even a master programmer, the guru of this forum, Jon Skeet, missed! (He knows this I'm sure, but just didn't think this was my problem; LOL, I am needling him) If...
2
1998
crabpot8
by: crabpot8 | last post by:
I am working on a message system that will let out programmers easily output a message to any user. It works fine, unless the message is requested inside of a page_load on an aspx page. Then, it does not render at all. The code does step through, and the control is added - I believe it might be being added to late in the page lifecycle to get rendered. I can't seem to find any way to tell .NET to render that control, however. ...
0
9621
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
9454
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,...
1
10039
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,...
0
9914
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...
1
7461
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 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...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4009
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
3610
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2851
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.