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

Making a click on a disabled cell move the row

Hi. I have a GridDataBoundGrid (2.0.5.0) that displays multiple rows per record (it''s derived from your MultiRowRecord example). I''d like to select whatever record the user clicks on, even if they''ve clicked on a disabled cell. As best as I can tell, some code like this should work: private void Grid_CellClick (object sender, GridCellClickEventArgs e) { GridDataBoundGrid grid = sender as GridDataBoundGrid; if (grid != null && !grid[e.RowIndex, e.ColIndex].Enabled) { GridBoundRecordState rs = grid.Binder.GetRecordStateAtRowIndex (e.RowIndex); this.gridRecordNavigationControl.CurrentRecord = rs.Position + 1; } } Now, rs.Position correctly returns the 0-based record number that I want. However, assigning into CurrentRecord (or NavigationBar.CurrentRecord; same effect) seems to act strangely. A) I assign 4, and it becomes 1. B) I assign 4 again, and it becomes 7. C) Go to (A) Its behavior seems to depend on what the current record setting is before the assignment, somehow. I''ve tried grid.CurrentCell.MoveTo, but that seemed to have no effect at all. Please, what am I missing? Thanks, Tom

5 Replies

AD Administrator Syncfusion Team May 13, 2004 07:17 PM UTC

I tried to see this problem using the MulipleRowPerRecord sample using your CellClick code. It seems to work for me in this sample. What are you doing differently? CS_3786.zip


TJ TJ May 13, 2004 07:52 PM UTC

Hi, Clay. Thanks for the quick response! I can duplicate the problem in the sample .ZIP that you gave me. Switch into multiple-row mode, then click back and forth between the disabled city names on the 2nd and 3rd rows (both "Mexico D.F."). Sometimes it''ll work properly, and sometimes it''ll jump to the 1st or 4th rows instead. Does it do that for you too? That''s roughly the behavior I''ve been seeing in my own app. (I''m using Windows 2000, VS .NET 2003 7.1.3088, targeting .NET 1.1.4322, have all the Windows critical updates, and no viruses or spyware). Thanks, Tom


AD Administrator Syncfusion Team May 13, 2004 09:12 PM UTC

I can see a problem if while clicking, ocassionally click on a enabled cell. This seems to get things out of sync. Using CurrentCell.MoveTo seemed to handle this problem. Just make sure you also set the ColIndex so you are trying to put the current cell on a cell that is enabled.
private void gridDataBoundGrid1_CellClick(object sender, GridCellClickEventArgs e)
{
	GridDataBoundGrid grid = sender as GridDataBoundGrid;
	if (grid != null && !grid[e.RowIndex, e.ColIndex].Enabled)
	{
		grid.CurrentCell.MoveTo(e.RowIndex, 1);
	}
}


TJ TJ May 14, 2004 01:52 PM UTC

That''s close enough for my purposes, and it works! Thanks, Tom


AD Administrator Syncfusion Team December 15, 2004 10:45 AM UTC

Hi Clay With this code, it works also when the first column is not enabled: GridDataBoundGrid grid = sender as GridDataBoundGrid; if (grid != null && !grid[e.RowIndex, e.ColIndex].Enabled) { grid.CurrentCell.MoveTo(e.RowIndex, 0); } The first and the third columns are not enabled, the focus is now on the second column. Regards, Thomas

Loader.
Live Chat Icon For mobile
Up arrow icon