How do I add PopupMenuItems in grid at runtime.

Hi,

I have added a PopupMenuItems in a data grid at runtime based on the data from database. I need to do different activities for different PopupMenuItems click event. How can i do this?

Here is the code which I wrote, but the problem is how can I identify which barItem is clicked when "barItem_Click" event is fired.

BarItems barItems = new BarItems;
for (int i = 1; i <= 5; i++)
{
BarItem b = new BarItem();
b.Text = i.ToString();
b.Checked = true;
b.Click += new EventHandler(barItem_Click);
barItems.Add(b);
}
grid.PopupMenuItems = barItems;

Thanks,
-Ravi.

1 Reply

AD Administrator Syncfusion Team December 14, 2006 07:06 AM UTC

Hi Ravi,

Use the Name/Text property to find the BarItem in a BarItem.Click event. Here is a code snippet

private void barItem_Click(object sender, System.EventArgs e)
{
BarItem b = sender as BarItem;
if( b.Name == "barItem1")
{
MessageBox.Show("BarItem[1] is Clicked");
}
}

Best Regards,
Haneef

Loader.
Up arrow icon