Skip to main content Skip to footer

Creating a ContextMenu for Tiles in C1TileControl

Background:

How to create a ContextMenu for Tiles in C1TileControl.

Steps to Complete:

1. Create a ContextMenuStrip and assign it to the ContextMenuStrip property of C1TileControl.

c1TileControl1.ContextMenuStrip = contextMenuStrip1;

2. Handle the MouseClick and TileChecked/TileUnchecked events of C1TileControl in order to show the context menu at right place.

Point point = new Point();
 private void C1TileControl1_MouseClick(object sender, MouseEventArgs e){
if(e.Button == MouseButtons.Right)
{
  c1TileControl1.TileUnchecked += C1TileControl1_TileUnchecked;
  c1TileControl1.TileChecked += C1TileControl1_TileChecked;
  point = e.Location;
  c1TileControl1.ContextMenuStrip = null;
}
else
{
c1TileControl1.TileUnchecked -= C1TileControl1_TileUnchecked;
c1TileControl1.TileChecked -= C1TileControl1_TileChecked;
  }
}

private void C1TileControl1_TileChecked(object sender, C1.Win.C1Tile.TileEventArgs e)
{
  contextMenuStrip1.Show(PointToScreen(point));
  contextMenuStrip1.Items[0].Text = e.Tile.Name;
 }
private void C1TileControl1_TileUnchecked(object sender, C1.Win.C1Tile.TileEventArgs e)
{
contextMenuStrip1.Show(PointToScreen(point));
contextMenuStrip1.Items[0].Text = e.Tile.Name;
}

Prabhat Sharma