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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Activate cell in grouping grid

Thread ID:





34397 Sep 8,2005 03:21 PM UTC Sep 29,2005 08:13 AM UTC WinForms 9
Tags: GridControl
Administrator [Syncfusion]
Asked On September 8, 2005 03:21 PM UTC

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.

Administrator [Syncfusion]
Replied On 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 Can you see the problem in this sample?

Administrator [Syncfusion]
Replied On 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;

Administrator [Syncfusion]
Replied On 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;

Administrator [Syncfusion]
Replied On 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.

Administrator [Syncfusion]
Replied On 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)
		base.WndProc (ref m);

Administrator [Syncfusion]
Replied On September 10, 2005 12:04 PM UTC

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

Administrator [Syncfusion]
Replied On 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

Administrator [Syncfusion]
Replied On 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

Administrator [Syncfusion]
Replied On 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.


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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

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