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

Translating child events into parent-control events

I have a problem I hope you folks can help me with.

I have an application that is using a tab-based interface, with the ability
for users to drag an item from a ListBox onto the tab control. This will
create a new tab, put a new instance of the proper UserControl into the tab,
and populate said UserControl with the data culled from the drop source.

Because of the nature of this application, the particular UserControl that
will be placed in the tabpage is constructed "on the fly" - the control is
created, linked to event handlers, and added to the tab control all in code.
I'm using a third-party tab control, but it's conceptually no different than
the MS tab control. I have the tab control's events hooked during
design-time, but since they can drag anywhere in the general tab page, each
page's UserControl has to have its drag/drop events hooked as well -
otherwise, once a tab page is created, the only place the user can
successfully drop is on the actual tabs (not the user experience I'm looking
for.)

My problem is that the UserControls I'm using all have child controls in
them, and while I can programmatically hook the UserControl's drag/drop
events, that hookup doesn't apply to its child controls. So when the user
drags their selection over the UserControl, all is well - but once they hit
a child control, they get a "you can't drop here" reaction, since the child
controls are not hooked to the same event(s) as the UserControl itself. It
makes for a very weird user experience.

I don't want to hardcode the drag/drop functionality within the specific
UserControls, since if I change the behavior in the form, I have to hit
every UserControl as well. I also don't want to try and implement some sort
of "For Each c as Control in UserControl..." loop, since some controls don't
support drag/drop functionality, and I don't want to write a lot of
type-testing code to figure out what I should hook up.

My intial thought was to try and develop some sort of method where I could
trap the assignment of the event delegate and propagate that to the child
controls, but (a) that's backwards to the Windows model - events move up the
window chain, not down - and (b) I could find nothing to help me in that
regard. So, now I'm looking at trying to code all my child controls to
raise the UserControl's appropriate drag/drop events in response to theirs,
so that they "bubble up" the chain - through the system-defined drag/drop
event for the UserControl. That way, my AddHandler hookup would see it, and
the .NET drag/drop code would take over from there. But RaiseEvent won't
raise a system-defined event on a control, and I have had no luck in trying
to create a delegate off the system events.

Does anyone have any idea how to make this work? Am I going about this the
wrong way?

TIA

- Scott
Nov 20 '05 #1
0 1821

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

Similar topics

1
by: ahaideb | last post by:
I have a table (relation) in my database: --------------- | parent | child | --------------- | 1 | 2 | | 1 | 3 | | 2 | 4 | | 2 | 5 ...
7
by: David Sobey | last post by:
hi Here's some code: void SomeFunc(childClass arg); .... parentClass a; a=new childClass(); SomeFunc(a);
2
by: Roderick Bloem | last post by:
I am going to take the liberty of crossposting this to comp.lang.c++ (originally comp.lang.c), and to summarize the discussion for the sake of those reading only c++. The question is: If you are...
11
by: Alberto Giménez | last post by:
Hi, I've seen some object oriented programming bits out there and i'm not sure if they're legal. For example: struct Object { int field1; int field2; }; struct SubObject { int field1; /*...
4
by: Danny Tuppeny | last post by:
Hi all, I've been trying to write some classes, so when I have a parent-child relationship, such as with Folders in my application, I don't have to remember to add a parent reference, as well as...
7
by: msxkim | last post by:
How to execute functions in the parent class first and then functions in the child class? For example, I have a parent class with functions 'ONE' and 'TWO' and child class has a function 'THREE'. ...
5
by: PAUL | last post by:
Hello, I have 2 tables with a relationship set up in the dataset with vb ..net. I add a new record to the parent table then edit an existing child record to have the new parent ID. However when I...
10
by: Dave | last post by:
Anyone familiar with PHP? I'm trying to make a translation. In PHP you can get the current object's name by going like this: get_class(item) == 'ClassName' I've tried type(item), but since I...
10
by: Goran Djuranovic | last post by:
Hi all, Does anyone know how to declare a variable in a class to be accessible ONLY from a classes instantiated within that class? For example: ************* CODE ***************** Public...
4
by: jewel87 | last post by:
Hi everyone! I'm writing some code in C under UNIX, which should give some output like this: PARENT: pid = 10063 CHILD: my pid = 10064 CHILD: my parent's pid = 10063 CHILD: Sleeping... PARENT:...
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: 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:
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
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
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
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
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.