Custom Control - Event Handling
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
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
SIGN IN To post a reply.
6 Replies
HA
haneefm
Syncfusion Team
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
Please refer this.
http://www.syncfusion.com/support/forums/message.aspx?&MessageID=60375
Best regards,
Haneef
RC
Russell Coombes
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
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
HA
haneefm
Syncfusion Team
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
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
RC
Russell Coombes
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
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
HA
haneefm
Syncfusion Team
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
Please refer to the attached sample and let me know if this helps.
TwoTextBoxCell.zip
Best regards,
Haneef
RC
Russell Coombes
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
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
SIGN IN To post a reply.
- 6 Replies
- 2 Participants
-
RC Russell Coombes
- May 3, 2007 04:35 PM UTC
- May 6, 2007 09:33 PM UTC