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.
Unfortunately, activation email could not send to your email. Please try again.

Making a click on a disabled cell move the row

Thread ID:

Created:

Updated:

Platform:

Replies:

13934 May 13,2004 12:49 PM Dec 15,2004 05:45 AM Windows Forms 5
loading
Tags: GridControl
TJ
Asked On May 13, 2004 12:49 PM

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

Administrator [Syncfusion]
Replied On May 13, 2004 03:17 PM

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
Replied On May 13, 2004 03:52 PM

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

Administrator [Syncfusion]
Replied On May 13, 2004 05:12 PM

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
Replied On May 14, 2004 09:52 AM

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

Administrator [Syncfusion]
Replied On December 15, 2004 05:45 AM

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

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.

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.

;