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. Image for the cookie policy date
close icon

Activate cell in grouping grid

I have a MDI app with 1. An XP tools "detached control bar" with a TreeViewAdv on. 2. Several ordinary MDI child window with grouping grids. If the control bar is active and I click a cell in one of the grouping grids, I have to click twice before the cursor is moved to the clicked cell. The first click has no noticeable effect, while the second click moves the current cell to the one that is clicked. It should only be neccesarry with one click to achieve this effect. Strangely enough this problem only occurs if the MDI child that is cliked is the active one. If I switch from the control bar to a non-active MDI child, only one click is needed. (It activates the MDI child and moves the current cell, as expected.) In the case that requires to clicks, I have checked all the Clicked events of the GridGroupingControl and it seems that none of them are fired on the first click. Do know what the problem may be here, and what I can do to solve it? (I''m using v. 3.2.1.0)

9 Replies

AD Administrator Syncfusion Team September 8, 2005 11:31 PM UTC

I tried to see the problem in this sample. http://www.syncfusion.com/Support/user/uploads/cs_2e8d9492.zip I can have the focus on one of the comboboxes in th etoolbar, and then click directly into a GridGroupingControl without seeing the problem. I am using 3.3.0.0. Can you see the problem in this sample?


AD Administrator Syncfusion Team September 9, 2005 11:23 AM UTC

It seems like the problem only occur with the GridCellActivateAction.DblClickOnCell option. After adding the following line (at the end of the Document_Load method) I see the problem in your sample: this.gridGroupingControl1.TableModel.Options.ActivateCurrentCellBehavior = Syncfusion.Windows.Forms.Grid.GridCellActivateAction.DblClickOnCell;


AD Administrator Syncfusion Team September 9, 2005 12:57 PM UTC

Hi Kjetil, You can make use of the ClickOnCell to focus the control on a cell by clicking once instead of "DoubleClick" to activate the cell. Here is the code to activate by single click. this.gridGroupingControl1.TableModel.Options.ActivateCurrentCellBehavior = Syncfusion.Windows.Forms.Grid.GridCellActivateAction.ClickOnCell;


AD Administrator Syncfusion Team September 9, 2005 03:29 PM UTC

I am aware of the ClickOnCell option, but I want to use the DoubleClick option instead. (When entering a large table of numbers I think it is much more efficient, since it is not necessary to delete the old table entries before entering the new ones.) So, if you can think of a workaround that solves the activate problem with the DoubleClick option I would be very happy.


AD Administrator Syncfusion Team September 9, 2005 03:54 PM UTC

This worked for me. It overrides the grid''s WndProc and set the focus when it gets an activate message.
public class MyGridGroupingControl : GridGroupingControl
{
	protected override void WndProc(ref Message m)
	{
		if(m.Msg == 0x21)// (WM_MOUSEACTIVATE)
		{
			this.Focus();
			return;
		}
		base.WndProc (ref m);
	}
}


AD Administrator Syncfusion Team September 10, 2005 12:04 PM UTC

This worked for me as well. Problem solved! Thanks a lot!


AD Administrator Syncfusion Team September 28, 2005 07:56 AM UTC

Hi Clay. I just discovered a problem with this solution. Under the following conditions clicking a cell in the grid will not work as expected: - Current cell is scrolled out of view - Grid does not have focus. - User clickes a cell in the (non-focused) grid. In this case the current cell will move to a different cell than the one that is clicked which is very confusing. I believe the reason is that the this.Focus(); line in the WndProc makes the grid scroll back to the previous current cell. After that the move of the current cell does not go to the one that was clicked. Can you suggest another workaround that solves this issue? Thanks, Kjetil


AD Administrator Syncfusion Team September 28, 2005 12:23 PM UTC

Hi Kjetil, Can you try this code in the WndProc override to see if it helps: public class MyGridGroupingControl : Syncfusion.Windows.Forms.Grid.Grouping.GridGroupingControl { protected override void WndProc(ref Message m) { if(!this.Focused && !this.TableControl.Focused) { if(m.Msg == 0x21)// (WM_MOUSEACTIVATE) { Point pt = this.TableControl.PointToClient(Control.MousePosition); int row=0, col=0; this.TableControl.PointToRowCol(pt, out row, out col); System.Diagnostics.Trace.WriteLine("RowIndex = " + row + " ColIndex = " + col); if(row != -1 && col != -1) { this.TableControl.CurrentCell.MoveTo(row,col); } return; } base.WndProc (ref m); } else base.WndProc (ref m); } } Best regards, Jay N


AD Administrator Syncfusion Team September 29, 2005 08:13 AM UTC

Hi Jay. I tried your code and it solved both problems above. I got another problem in my app, though. I have a handler for the TableControlCurrentCellMoved event which depends on the grid being focused. This was now called before the grid got focus. To solve this I defferred the CurrentCell.MoveTo call to Application.Idle. Now everything seems to work fine. Thanks a lot for your support on this.

Loader.
Live Chat Icon For mobile
Up arrow icon