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

Resetting current cell

Thread ID:

Created:

Updated:

Platform:

Replies:

22496 Dec 14,2004 02:48 PM UTC Sep 14,2015 04:55 AM UTC WinForms 11
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On December 14, 2004 02:48 PM UTC

Maybe this is obvious and I''m just missing it, but when a grid is first displayed, the current cell is -1, -1 and there is no real current cell in the grid. How do you get the grid back to this state, programmatically? In other words, the user has clicked on a cell. After a certain event, I want the grid to go back to the state where there is no current cell. Thanks.

Administrator [Syncfusion]
Replied On December 14, 2004 03:05 PM UTC

You can try calling grid.CurrentCell.MoveTo(-1, -1). As long as the event you are using is not in the middle of the grid moving the currentcell, then the above will probably work. If you are in teh middle of moving a currentcell when you want to do this, set a flag and then use CurrentCellMoved to trest your flag and reset things there is needed.

Administrator [Syncfusion]
Replied On December 14, 2004 06:22 PM UTC

>You can try calling > >grid.CurrentCell.MoveTo(-1, -1). > > >As long as the event you are using is not in the middle of the grid moving the currentcell, then the above will probably work. If you are in teh middle of moving a currentcell when you want to do this, set a flag and then use CurrentCellMoved to trest your flag and reset things there is needed. That''s not working for me. I''m not in the middle of changing the current cell, but I''m in the middle of a LOT of things going on, so let me try to lay ou the sequence of events here. First of all, a bit of background. This is a databound grid, but not the SyncFusion GridDataBoundGrid control. We''ve done our own data binding using the GridControl as the base class. The bug I''m trying to fix is that if someone edits a cell and that cell is the current cell, and then they set the DataSource to null, all the data in the grid disappears except for the data in that cell. The sequence of events when the DataSource is set to null is: CurrentCell.EndEdit(); CurrentCell.MoveTo(-1, -1); <--- doesn''t work this.EndEdit(); listManager.EndEdit() Model.ResetVolatileData(); listManager is the CurrencyManager object. "this" is the class derived from GridControl. My hope was that setting the current cell to -1, -1 before clearing out the listManager would fix the problem, but after this call, the current cell does not appear to change at all. We''re using a virtual grid and if the DataSource is null, QueryCellInfo() doesn''t do anything, so I can''t figure out why the data in the selected cell is still there. I''ve also tried things like this.Clear(true), this.Clear(false). Nothing seems to clear out that cell. Pete

Administrator [Syncfusion]
Replied On December 14, 2004 08:35 PM UTC

Try adding another call to Model.ResetVolatileData(); right after you call CurrentCell.EndEdit.

Administrator [Syncfusion]
Replied On December 14, 2004 10:45 PM UTC

Didn''t seem to make any difference.

Administrator [Syncfusion]
Replied On December 14, 2004 11:20 PM UTC

Here are some other calls you could try. grid.CurrentCell.RejectChanges() grid.CurrentCell.ResetCurrentCellWithoutDeactivate(); If you could upload a little sample, we could try to find a solution.

Administrator [Syncfusion]
Replied On December 15, 2004 12:48 PM UTC

Unfortunately, there''s no way to do a "little sample". My derived grid control makes use of other control libraries that are part of our system and my grid control itself consists of some 30 classes or so with 4000 lines of code in the derived grid.cs file alone. Why don''t we investigate why the CurrentCell.MoveTo() isn''t working. What I''ve done is placed a button on my test form and the code for the click event is simply: mozartGrid1.CurrentCell.MoveTo(-1, -1); I click the button once, then I click it again. On the second click, I set a breakpoint before this line is executed so I can see what the result of the previous MoveTo() was. MoveTo() always seems to return false. CurrentCell.ColIndex and RowIndex are still their previous values (positive numbers), but the MoveToColIndex and MoveToRowIndex are both -1. Now, the weird thing is if I put a breakpoint in the Click() method for the button where I set the current cell, I get the following dumped from the grid over and over again, if it helps... Invalid state: IsInMoveTo returns false GridCurrentCell.get_MoveFromColIndex(-1, mozartGrid1 VokCfo CC: { Act R2C1 Edi }) 0: called from Form1.currCellButton__Click(Object, EventArgs) in form1.cs:line 192 1: called from Control.OnClick(EventArgs) in :line 0 2: called from Button.OnClick(EventArgs) in :line 0 3: called from Button.OnMouseUp(MouseEventArgs) in :line 0 4: called from Control.WmMouseUp(Message&, MouseButtons, Int32) in :line 0 5: called from Control.WndProc(Message&) in :line 0 6: called from ButtonBase.WndProc(Message&) in :line 0 7: called from Button.WndProc(Message&) in :line 0 8: called from ControlNativeWindow.OnMessage(Message&) in :line 0 9: called from ControlNativeWindow.WndProc(Message&) in :line 0 10: called from NativeWindow.DebuggableCallback(IntPtr, Int32, IntPtr, IntPtr) in :line 0 11: called from UnsafeNativeMethods.DispatchMessageW(MSG&) in :line 0 12: called from ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(Int32, Int32, Int32) in :line 0 13: called from ThreadContext.RunMessageLoopInner(Int32, ApplicationContext) in :line 0 14: called from ThreadContext.RunMessageLoop(Int32, ApplicationContext) in :line 0 15: called from Application.Run(Form) in :line 0 16: called from Form1.Main() in form1.cs:line 172 What kinds of thing can prevent setting the current cell from working? I don''t know if it makes a difference, but we''ve got ExcelLikeCurrentCell = true. ExcelLikeSelectionFrame = false. Thanks. Pete

Administrator [Syncfusion]
Replied On December 15, 2004 02:56 PM UTC

To see why mozartGrid1.CurrentCell.MoveTo is failing, I think you will need use the Assembly Manager to get a debug build of our libraries, and then step into our code to see where things go wrong. If we could get a sample, this is what we would try first.

vbaker
Replied On December 15, 2004 05:38 PM UTC

I found that these two methods are really helpful in de-activating the current cell as well as any other, "selected" cells: this.CurrentCell.SetCurrentCellNoActivate(-1, -1); this.Selections.Clear(); Maybe it''ll work for you too. Regards, --Van Baker

Administrator [Syncfusion]
Replied On December 15, 2004 07:09 PM UTC

Since the moveToRowIndex was changed, that means part of MoveTo were able to execute. There it does not seem the current cell is locked (see IsLocked). Instead some event is blocking the deactivation of the current cell. Possible events are CurrentCellMoving, CurrentCellDeactivating, CurrentCellValidatXYZ, CurrentCellEndEditing and CurrentCellConfirmingChanges. Do you handle any of these events? Is CurrentCellMoveFailed called? As Clay said, best way to find out is to debug into the MoveTo code. Stefan

Maxim Software Systems
Replied On September 11, 2015 05:46 PM UTC

"when a grid is first displayed, the current cell is -1, -1 and there is no real current cell in the grid. How do you get the grid back to this state, programmatically?"

This question still remains unanswered, unfortunately.

Adhikesevan Kothandaraman [Syncfusion]
Replied On September 14, 2015 04:55 AM UTC

Hi Arthur,

Thank you for your update.

To programmatically set the current cell location to (-1,-1), use the CurrentCell.MoveTo method. Please refer to the below KB document to move the current cell location to (-1,-1).

KB Link:

https://www.syncfusion.com/kb/777/how-can-you-not-have-a-current-cell-in-the-grid   

Regards,

Adhi

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.

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

;