Raising events from constituent controls

S

snesbit

If a screen is made up of several user controls and those user controls contain various packaged or standard controls such as a grid, how do you raise both standard and custom events from the user control so the form containing the user control can see the events you want them to see.


Help Please....
 
P

Peter Proost

Hi

on the user control you need to declare a public event and raise it with
raiseevent youreventname, you raise the event on the usercontrol when
something hapens on the usercontrol that you want the form to be aware of.

if you've declared an event and placed the raiseevent where you need it in
the usercontrol. You can catch it in the code of your form containing the
control by going to the code editor and than in the left combo where you
select all your controls, select your control. Next in the right combo you
will be able to select your event you declared.

Hth Peter


--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.

"snesbit" <[email protected]> schreef in bericht
If a screen is made up of several user controls and those user controls
contain various packaged or standard controls such as a grid, how do you
raise both standard and custom events from the user control so the form
containing the user control can see the events you want them to see.


Help Please....
 
S

snesbit

Peter,

I think I understand, but let me clarify


Example

User Control contains an infragistics grid (that
has its own events)

I place the User Control on a new form.

I want to see/use specific infragistics grid
events on the new form.

Best approach to solve?
 
P

Peter Proost

Hi,

for example your infragistics grid (infragisticsGrid) has an event called
gridFilled, and you place the infragisitics grid on a usercontrol called
MyUsercontrol

then in your usercontrol you will have something like

private sub infragisticsGrid_GridFilled (.....) handles infragistics.filled

end sub

now you need to declare and raise an event in your usercontrol like this

Public event MyGridIsFilled ()

and then raise it inside the infragisticsGrid_GridFilled (.....)

so it will look like this:

Public event MyGridIsFilled ()

private sub infragisticsGrid_GridFilled (.....) handles
infragisticsGrid.filled
RaiseEvent MyGridIsFilled
end sub


now on your form in the code you can select in the left combo your
usercontrol (MyUsercontrol)
and in the right combo there will be an event MyGridIsFilled. If you select
something like this will be created

Private sub MyUserControl_MyGridIsFilled(.....) handles
MyUserControl.MyGridIsFilled

End sub


Hope it's clear

greetz Peter
 
S

snesbit

Got it ...Thanks

Peter Proost said:
Hi,

for example your infragistics grid (infragisticsGrid) has an event called
gridFilled, and you place the infragisitics grid on a usercontrol called
MyUsercontrol

then in your usercontrol you will have something like

private sub infragisticsGrid_GridFilled (.....) handles infragistics.filled

end sub

now you need to declare and raise an event in your usercontrol like this

Public event MyGridIsFilled ()

and then raise it inside the infragisticsGrid_GridFilled (.....)

so it will look like this:

Public event MyGridIsFilled ()

private sub infragisticsGrid_GridFilled (.....) handles
infragisticsGrid.filled
RaiseEvent MyGridIsFilled
end sub


now on your form in the code you can select in the left combo your
usercontrol (MyUsercontrol)
and in the right combo there will be an event MyGridIsFilled. If you select
something like this will be created

Private sub MyUserControl_MyGridIsFilled(.....) handles
MyUserControl.MyGridIsFilled

End sub


Hope it's clear

greetz Peter





--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.

it
 
D

durstin

If you want the events of the consituent controls available to the designer, you have to define wrapper events in the container control and stitch the events up by hand (i.e., in code). See http://winfx.msdn.microsoft.com/lib...html/8242a3f4-25cb-4475-b7a8-9d8aec5c662b.asp. If you want the events available programmatically only, then you can make the constituent controls public--this is of course an all or nothing affair.

If a screen is made up of several user controls and those user controls contain various packaged or standard controls such as a grid, how do you raise both standard and custom events from the user control so the form containing the user control can see the events you want them to see.


Help Please....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top