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

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 3176
On 2007-11-20 14:55:02 -0800, Eitan <Ei***@discussions.microsoft.comsaid:
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.TextChanged 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 RockerStateChanged 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.de

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 RockerStateChanged 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***@discussions.microsoft.comsaid:
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.TextChanged 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 RockerStateChanged 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***@discussions.microsoft.comsaid:
My problem is how to expose RockerStateChanged 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
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...
2
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...
11
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...
5
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...
10
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...
6
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...
1
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)....
12
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....
2
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...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...
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,...

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.