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

Selection problems

Hello, I've created a virtual tree grid based on the sample project you provide ('VirtTreeGrid') and noticed that in both my grid and the sample a selection cannot be initiated when the first cell clicked on is one of the cells that uses the 'TreeCellModel'. What can I do get around this? Thanks, Terry

2 Replies

AD Administrator Syncfusion Team May 14, 2003 07:25 PM UTC

The OnHitTest returns a nonzero anytime the mouse is over one of the treecells. This means the selection mouse controller that manages selecting cells does not get a crack at selecting things. So, if you want to allow selections, you will have to refine teh OnHitTest to only return a nonzero when you do not want the selection controller to handle things. Below is a snippet that returns a non-zero only if the mouse is over the cell bitmap.
protected override int OnHitTest(int rowIndex, int colIndex, MouseEventArgs e, IMouseController controller) 
	if(e.Button != MouseButtons.None )
		Rectangle rect = GetCellBoundsCore(rowIndex, colIndex);
		int X = rect.X + IndentSize * (int)this.Grid.Model[rowIndex, colIndex].Tag;
		rect.X = X;
		rect.Width = this.bitmapWidth;
		rect.Height = this.bitmapHeight;
		if(rect.Contains(new Point(e.X, e.Y)))
			return GridHitTestContext.Cell; 
		return 0;

TF Terry Foster May 15, 2003 11:48 AM UTC

Awesome - thanks! Terry

Live Chat Icon For mobile
Up arrow icon