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.
Unfortunately, activation email could not send to your email. Please try again.

Grid Inherited user control

Thread ID:

Created:

Updated:

Platform:

Replies:

62628 Jun 19,2007 11:55 AM Jun 20,2007 06:47 PM Windows Forms 3
loading
Tags: GridControl
Jogesh Menon
Asked On June 19, 2007 11:55 AM

Hi,

I want to create a custom Inherited user control which derives from the syncfusion grid. I want to create a base grid with extended functionality,(like a standard menu for right clicks) that other developers can further extend. I tried creating an inherited user control in VS 2005, But could not. Am I on the right track or should I create a plain user control which wraps around the syncfusion grid object?

Any Insight would be helpful.

Thanks,
Jogesh.

haneefm [Syncfusion]
Replied On June 19, 2007 05:02 PM

Hi Jogesh,

You would have to derive the GridControl and set ContextMenu property to display the standard menu in a grid when you right clicked on the cell. Here is a code snippet to show this.

public class MyGridControl : GridControl
{
public delegate void objContextMenuClick(object sender ,EventArgs e);
public event objContextMenuClick ContextMenuClick;

public MyGridControl()
{
ContextMenu menu = new ContextMenu();

menu.MenuItems.Add("Copy");
menu.MenuItems.Add("Paste");
menu.MenuItems.Add("Edit");

for(int i = 0;i< menu.MenuItems.Count;i++)
menu.MenuItems[i].Click += new EventHandler(OnContextMenuClick);

this.ContextMenu = menu;
}

void OnContextMenuClick(object sender, EventArgs e)
{
if (ContextMenuClick != null)
{
ContextMenuClick(sender, e);
}
}
}

Please refer to the attached sample for implementation and let me know if this helps.
InheritedGridControl.zip

Best regards,
Haneef

Jogesh Menon
Replied On June 20, 2007 10:13 AM

Hi, Haneef,

Thank you for the prompt response. your code snipet is helpful, but what I am trying to get at is a bit different.

If I want to create a customised control based on syncfusion grid Can I

A) Create an Inherited Custom control(in VS2005)
B) Use Inheritance

From you response It seems that you have taken the inheritance approach, is approach # 1 possible ?

Thanks,
Jogesh


>Hi Jogesh,

You would have to derive the GridControl and set ContextMenu property to display the standard menu in a grid when you right clicked on the cell. Here is a code snippet to show this.

public class MyGridControl : GridControl
{
public delegate void objContextMenuClick(object sender ,EventArgs e);
public event objContextMenuClick ContextMenuClick;

public MyGridControl()
{
ContextMenu menu = new ContextMenu();

menu.MenuItems.Add("Copy");
menu.MenuItems.Add("Paste");
menu.MenuItems.Add("Edit");

for(int i = 0;i< menu.MenuItems.Count;i++)
menu.MenuItems[i].Click += new EventHandler(OnContextMenuClick);

this.ContextMenu = menu;
}

void OnContextMenuClick(object sender, EventArgs e)
{
if (ContextMenuClick != null)
{
ContextMenuClick(sender, e);
}
}
}

Please refer to the attached sample for implementation and let me know if this helps.
InheritedGridControl.zip

Best regards,
Haneef


haneefm [Syncfusion]
Replied On June 20, 2007 06:47 PM

Hi Jogesh,

Here is a minimal sample that shows this task.
InheritedUser.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.

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.

;