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

Problem with CurrentCell not changing

Thread ID:

Created:

Updated:

Platform:

Replies:

3539 Mar 27,2003 01:19 PM UTC Mar 28,2003 06:46 PM UTC WinForms 5
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On March 27, 2003 01:19 PM UTC

I have a Grid Control (non-databound) that I ocassionally reload the entire grid. Before reloading I execute the following code to clear out the data: gridControl1.Focus(); gridControl1.CurrentCell.MoveTo(-1, -1); gridControl1.ClearCells(GridRangeInfo.Table(), true); gridControl1.RowCount = 0; After reloading the data my CurrentCell is still set to the previous row that was selected before the above code was executed. I have trapped in the CurrentCellMoving event and it does get executed on the moveto method. Any ideas?

Administrator [Syncfusion]
Replied On March 27, 2003 03:13 PM UTC

I tried this code in a button handler and things seemed to work as expected.
private void button1_Click(object sender, System.EventArgs e)
{
	gridControl1.Focus();
	gridControl1.CurrentCell.MoveTo(-1, -1);
	gridControl1.ClearCells(GridRangeInfo.Table(), true);
	gridControl1.RowCount = 0;

	MessageBox.Show("EmptyGrid");

	gridControl1.Focus();
	gridControl1.RowCount = 20;
}
You might use the Debug|Exceptions menu item to set Common Language Runtime exceptions to break into teh debugger to see if there is some type of exception being thrown that would interfere with this behavior. Also, when you perform this code, what is teh state of the grid at that point? Is this code being call from an event handler that might not expect the RowCount to change? If you can reproduce the behavior in a sample project, you can submit in a Direct Trac support incident, and we will take a look at it to see if we can spot what is going on.

Administrator [Syncfusion]
Replied On March 27, 2003 06:17 PM UTC

The following exception is thrown when I do the moveto(-1,-1): System.ArgumentException: negative key at Syncfusion.Windows.Forms.Grid.GridIndexDictionary.OnValidate(Object key, Object value) at Syncfusion.Collections.TypedDictionaryBase.System.Collections.IDictionary.set_Item(Object key, Object value) at Syncfusion.Windows.Forms.Grid.GridIndexDictionary.set_Item(Int32 key, Object value) at Syncfusion.Windows.Forms.Grid.GridRowColSizeDictionary.set_Item(Int32 index, Int32 value) at Syncfusion.Windows.Forms.Grid.GridModelRowColSizeIndexer.SetSize(Int32 index, Int32 value) at Syncfusion.Windows.Forms.Grid.GridModelRowColSizeIndexer.SetRange(Int32 from, Int32 to, Int32[] values, Boolean discardUndo) catched at Syncfusion.Windows.Forms.Grid.GridModelRowColSizeIndexer.SetRange(Int32 from, Int32 to, Int32[] values, Boolean discardUndo) in :line 0 which does cause the move to not occur. So how do I get the current row to be unset or point to -1,-1 like when the grid is intialized. > I tried this code in a button handler and things seemed to work as expected. >
> private void button1_Click(object sender, System.EventArgs e)
> {
> 	gridControl1.Focus();
> 	gridControl1.CurrentCell.MoveTo(-1, -1);
> 	gridControl1.ClearCells(GridRangeInfo.Table(), true);
> 	gridControl1.RowCount = 0;
> 
> 	MessageBox.Show("EmptyGrid");
> 
> 	gridControl1.Focus();
> 	gridControl1.RowCount = 20;
> }
> 
> > You might use the Debug|Exceptions menu item to set Common Language Runtime exceptions to break into teh debugger to see if there is some type of exception being thrown that would interfere with this behavior. > > Also, when you perform this code, what is teh state of the grid at that point? Is this code being call from an event handler that might not expect the RowCount to change? > > If you can reproduce the behavior in a sample project, you can submit in a Direct Trac support incident, and we will take a look at it to see if we can spot what is going on.

Administrator [Syncfusion]
Replied On March 27, 2003 11:16 PM UTC

Instead of MoveTo(-1, -1), try calling CurrentCell.Deactivate.

Administrator [Syncfusion]
Replied On March 28, 2003 02:10 PM UTC

That was actually the first thing I tried but after calling deactivate the currentcell.rowindex does not change. It only seems to change the IsActive to false.

Administrator [Syncfusion]
Replied On March 28, 2003 06:46 PM UTC

After Deactivate you can change the row and column index with CurrentCell.SetCurrentCellNoActivate Stefan

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

;