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
close icon

Problem with custom cell type in GridDataBoundGrid

I''m trying to create a custom cell type (using model and renderer classes) for use in a GridDataBoundGrid. I looked at some of the sample projects to get an idea on how to do this. But my efforts have not fully succeeded. I am using a DateTimePicker control in cells, and the dates are displaying. Strange things happen, though, when I click around the grid between different DateTimePicker cells. If I enter one DateTimePicker cell and then enter another, the first one will display the value of the second. If I change a value, the DateTimePicker goes blank until I leave the cell. And when I leave the cell, other cells display the new value. I have been unable so far to figure out what it is going on. I have included a sample app that showcases this problem. Thanks for your help, Brian GDBG_CustomCell_Problem_8601.zip

4 Replies

AD Administrator Syncfusion Team September 24, 2005 12:13 AM UTC

I tweaked your OnDraw as below to avoid the problem (essentially just positioning and showing the edit control without calling the base class).
protected override void OnDraw(Graphics g, Rectangle clientRectangle, int rowIndex, int colIndex, GridStyleInfo style)
{
	clientRectangle.Size = GridUtil.Max(clientRectangle.Size, GridCellDateTimePickerModel.DateTimePickerControlSize);

	if (this.ShouldDrawFocused(rowIndex, colIndex))
	{
		this.FixControlParent(_editDateTimePicker);

		// Position current grid.
		this._editDateTimePicker.Size = clientRectangle.Size;
		this._editDateTimePicker.Location = clientRectangle.Location;
		if (!this._editDateTimePicker.ContainsFocus)
			this._editDateTimePicker.Focus();

	}
	else
	{
		style.Control = this._viewDateTimePicker;
		GridCellDateTimePickerModel.InitializeDateTimePicker(this._viewDateTimePicker, style);
		base.OnDraw (g, clientRectangle, rowIndex, colIndex, style);
	}
}
If you just want a DateTimePicker cell, you can get one in this KB. http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=292


AD Administrator Syncfusion Team September 26, 2005 06:46 PM UTC

Clay, That really didn''t seem to help. When moving from one DateTimePicker cell to another, the previous one will display the value of the current one until you move to a non-DateTimePicker cell. And if you move between numerous DateTimePicker cells, there''s a large flicker in cells that were visited. On a side note, I''m actually using a custom date control that another developer created. I used the DateTimePicker control as a means to eliminate the custom control as a problem. I see the same effects regardless of which control I use. The DateTimePicker kept things simpler when creating my sample. Brian


AD Administrator Syncfusion Team September 26, 2005 07:24 PM UTC

Here is you sample back. With 3.3, I can change the value of one of the datetime cells, and then click on a another cell without seeing the duplicate values. Do you see the problem in this sample? http://www.syncfusion.com/Support/user/uploads/GDBG_CustomCell_Problem_9ecdf995.zip


AD Administrator Syncfusion Team September 26, 2005 08:08 PM UTC

Thanks for your help, Clay. I noticed that I had a typo when I took your modified code. I had put RowIndex and ColIndex instead of rowIndex and colIndex in OnDraw. Somehow I missed that. Everything works just fine now.

Loader.
Live Chat Icon For mobile
Up arrow icon