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

Cell Click Event ?

Thread ID:

Created:

Updated:

Platform:

Replies:

26138 Mar 15,2005 03:29 PM UTC Mar 15,2005 07:03 PM UTC Windows Forms 4
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On March 15, 2005 03:29 PM UTC

I have a form that does certain things based on which col the user clicks in. I have this code in the grd.cellclick event. I just noticed today that this event doesnt seem to happen if the user selects a range in a col. Is there an event i can use that will allow me to set up some code whether they click a single cell in a col or select a range of cells in a col?

Administrator [Syncfusion]
Replied On March 15, 2005 04:19 PM UTC

The cell click event is only raised if you mousedown and mouseup in the same cell. If you want to catch mousing down/up in possibly different rows, but the same column, then you can catch both events, and remember the mousedown column and test for it in the mouse up event.
private int mouseDownCol = -1;
private void gridControl1_MouseDown(object sender, MouseEventArgs e)
{
	int row;
	int col;
	Point pt = new Point(e.X, e.Y);
	if(this.gridControl1.PointToRowCol(pt, out row, out col))
		this.mouseDownCol = col;

}
private void gridControl1_MouseUp(object sender, MouseEventArgs e)
{
	int row;
	int col;
	Point pt = new Point(e.X, e.Y);
	if(this.gridControl1.PointToRowCol(pt, out row, out col)
		&& col == this.mouseDownCol)
	{
		Console.WriteLine("MouseUp/Down Column");
	}
	this.mouseDownCol = -1;
}

Administrator [Syncfusion]
Replied On March 15, 2005 04:50 PM UTC

That works for clicks but our users can also click one cell then use the arrow keys to move to another col and then select a range of cells with the arrow key. The mouseup and down doesnt work for that. I forgot to mention that. What im trying to do is this. I have one of your currencytextbox controls on a form with a grid. Depending on what col the user might click i update the data in the currencytextbox control and then it remembers that data so when they click another col and them move back it will put the data back the way it was for that col. So if the value of the currencytextbox control for col three is 3.35 and four is 5.55 then each time they click one of those cols it changes my currencytextbox control with the saved value whatever it may be. So everytime they click a new col i need to update that data. So is there something that will work no matter how a cell or range of cells gets selected in a certain col?

Administrator [Syncfusion]
Replied On March 15, 2005 05:27 PM UTC

Try using the CurrentCellMoved event to catch moving the currentcell with the keyboard or with clicking. You can use the properties, grid.CurrentCell.MoveToColIndex and grid.CurrenCell.MoveFromColIndex, to see where you are and where you came from. But as far as catching mousing down on one column and mousing up on another column, I think you will still need to use something like the previous suggestion to handle this. It is teh simplest way that I know to do it.

Administrator [Syncfusion]
Replied On March 15, 2005 07:03 PM UTC

Thanks. Works fine in the currentcellmoved event. I didnt have to put anything in the mouseup or down events. No matter how i move either by clicking a cell or dragging a range with the mouse or arrowing all over with the arrow keys it works no matter how i do it. Thanks again.

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

;