Exception in QueryNextEnabledCell

Hi, I get an exception NullReferenceException in QueryNextEnabledCell method when I use keyboard keys Left or Up to move the current cell left or up and there are only cells with Enabled==false left or above of it. My grid is virtual, I use event handlers for QueryColCount, QueryRowCount, QueryCellInfo, SaveCellInfo and QueryCoveredRange. As I have no source code, I cannot find the reason and workaround for that. I believe I have to set some other property on my disabled cells to avoid crash in QueryNextEnabledCell. Could you give me an idea, what can cause that exception in QueryNextEnabledCell ? I've attached the stack info as file. At that moment the current cell was on column 6, I pressed left. Columns 1 to 5 have Enabled=false. Thanks for hints. Regards, Jan

2 Replies

AD Administrator Syncfusion Team July 18, 2003 08:23 AM UTC

Here is the code.
case GridDirectionType.Left:
	while (targetCol >= 1 && !enabled)
	{
		// skip invisible and covered cells
		while (targetCol >= 1
			&& (grid.GetColWidth(targetCol) == 0
			|| gridModel.CoveredRanges.Find(targetRow, targetCol, out coveredRange)
			&& coveredRange.Left != targetCol
			)
			)
			targetCol--;

		if (targetCol >= 1)
		{
			gridModel.CoveredRanges.Find(targetRow, targetCol, out coveredRange);
			style = grid.GetViewStyleInfo(coveredRange.Top, coveredRange.Left);
			enabled = style.Enabled || grid.IsDesignMode();
			style.Dispose();

			// not enabled, continue search
			if (!enabled && targetCol >= 1)
				targetCol--;
		}
	}
break;
So, it does rely on covered cells heavily. If you can attach a sample project, or submit a Direct Trac support incident with a sample, we can see if we can spot something here.


JH Jan Hornych July 18, 2003 10:21 AM UTC

Thanks, it helped. My mistake was setting e.Range=null;e.Handled=true; in QueryCoveredRange event handler in case no covering was applicable for the cell. After change only to e.Handled=false; in this case, everything works fine. Thank you once more. Jan

Loader.
Up arrow icon