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.
Syncfusion Feedback

To get current cell

Thread ID:

Created:

Updated:

Platform:

Replies:

51837 Nov 15,2006 05:16 AM UTC Nov 15,2006 06:17 AM UTC Windows Forms 4
loading
Tags: GridControl
Sandeep
Asked On November 15, 2006 05:16 AM UTC


Hi,
I want to get the current cell of the databoundgrid.
There is currentcell property which gives me current cell only if I click that cell. But if I click/rightclick on the fixed row/column I dont get the exact value. I get only the previous cell values.
Like suppose I click on the header whose rowindex is 0. then I should get the rowindex and column index of it. Is there any way I can get it.

Thanks,
Sandeep

Sandeep
Replied On November 15, 2006 05:37 AM UTC


Hi,
I will tell you want I want to do.

I have attached context menu to the grid. But I want to display the context menu only if user clicks the cell and not the header or the left fixed column. Right now it displays context menu if I click anywhere on the grid.

Please provide me solution.

Thanks,
Sandeep

Administrator [Syncfusion]
Replied On November 15, 2006 05:40 AM UTC

Hi Sandeep ,

By default, The current cell gets activated after clicking on it ( Because of the default ActivateCurrentCellBehavior property setting of the grid). If you want to set the currentcell as a clicked cell, you need to use the CurrentCell.MoveTo method in CellClick/CellDoubleClick event. Here is a code snippet.

//Cellclick event
this.grid.CurrentCell.MoveTo(e.RowIndex,e.ColIndex);

Best Regards,
Haneef

Administrator [Syncfusion]
Replied On November 15, 2006 05:58 AM UTC

Hi Sandeep,

You can handle the MouseUp event of the GridControl and conditionally display a context menu for the grid cells. Here is a code snippet.

private void gridControl1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
if( e.Button == MouseButtons.Right )
{
GridControl grid = sender as GridControl;
Point pt = new Point(e.X,e.Y);
int row,col;
grid.PointToRowCol(pt,out row,out col);
if(row > 0 && col > 0)
this.contextMenu1.Show(this.gridControl1,pt);
}
}

Sample : http://www.syncfusion.com/Support/user/uploads/contextmenu_2453f1f0.zip

Best Regards,
Haneef

Sandeep
Replied On November 15, 2006 06:17 AM UTC

Hi Hanif,

Thank you very much. It solved my problem

Thanks,
Sandeep

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

;