We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Custom Control - Event Handling

Thread ID:

Created:

Updated:

Platform:

Replies:

60372 May 3,2007 04:35 PM UTC May 6,2007 09:33 PM UTC WinForms 6
loading
Tags: GridControl
Russell Coombes
Asked On May 3, 2007 04:35 PM UTC

Hi,

I have written a custom user control that I have placed into a GridGroupingControl using classes that implement 'GridGenericControlCellRenderer' and 'GridGenericControlCellModel'. The user control is displaying correctly, but I wish to listen for events that have been raised from it. There are two types of button on my user control, each of which raises their own event. What is best practice for capturing an event from a custom user control that is placed into the GridGroupingControl?

Regards,
Russell

haneefm [Syncfusion]
Replied On May 3, 2007 06:12 PM UTC

Hi Russell,

Please refer this.
http://www.syncfusion.com/support/forums/message.aspx?&MessageID=60375

Best regards,
Haneef

Russell Coombes
Replied On May 3, 2007 10:08 PM UTC

Hi Haneef,

Thanks for your reply - although I do not understand why you have you have sent me a link to another question that I had written that is completely unrelated to this topic!

The other message was related to capturing a grid cell event in order to resize the cell based on its contents.

My question here is:

How do I best handle the events raised from my custom control that are hosted within a grid?

Any information would be much appreciated.

Regards,
Russell

>Hi Russell,

Please refer this.
http://www.syncfusion.com/support/forums/message.aspx?&MessageID=60375

Best regards,
Haneef

haneefm [Syncfusion]
Replied On May 3, 2007 11:01 PM UTC

Hi Russell,

Sorry for the inconvenience caused.

You can try this code snippet to handle the usercontrol's cell event .

CellRenderName cr = this. gridGroupingControl1.TableControl.CellRenderers["CellTypeName"] as CellRenderName;
if( cr != null )
{
UserControl1 uc = cr.Control as UserControl1;
if( uc != null )
{
foreach(Control c in uc.Controls)
{
if( c is ChildUserControl)
{
ChildUserControl cuc = c as ChildUserControl;
//You can handle you event here....
cuc.EventName += new EventHandler(method);
}
}
}
}

Best regards,
Haneef

Russell Coombes
Replied On May 4, 2007 07:31 AM UTC

Hi Haneef,

Thanks for your quick reply.

I'd also like to know if it's possible for a custom user control placed in a grid is able to handle it's own events? For example, my UserControl has a button and a dropdown, and I would like each UserControl to be able to handle the click events for its button and drop-down without the grid taking over with the 'TableControlCellClick' event. Is this possible?

Regards,
Russell

>Hi Russell,

Sorry for the inconvenience caused.

You can try this code snippet to handle the usercontrol's cell event .

CellRenderName cr = this. gridGroupingControl1.TableControl.CellRenderers["CellTypeName"] as CellRenderName;
if( cr != null )
{
UserControl1 uc = cr.Control as UserControl1;
if( uc != null )
{
foreach(Control c in uc.Controls)
{
if( c is ChildUserControl)
{
ChildUserControl cuc = c as ChildUserControl;
//You can handle you event here....
cuc.EventName += new EventHandler(method);
}
}
}
}

Best regards,
Haneef

haneefm [Syncfusion]
Replied On May 4, 2007 07:26 PM UTC

Hi Russell,

Please refer to the attached sample and let me know if this helps.
TwoTextBoxCell.zip

Best regards,
Haneef

Russell Coombes
Replied On May 6, 2007 09:33 PM UTC

Hi Haneef,

I'm not sure that this sample does help me.

Firstly, I am using a GridGroupingControl, whilst the attached control is a GridDataBoundControl.

Secondly, I can see how the user control catches the event as set up on line 80 of the 'TwoTextBoxCell.cs'...but in my situation, my user control does not receive its 'Click' event because the Grid hides it with its own 'TableControlCellClick' event. Can you please explain how I can prevent this grid event from hiding my own UserControl's event?

Thanks!

Regards,
Russell


>Hi Russell,

Please refer to the attached sample and let me know if this helps.
TwoTextBoxCell.zip

Best regards,
Haneef

>Hi Russell,

Please refer to the attached sample and let me know if this helps.
TwoTextBoxCell.zip

Best regards,
Haneef

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;