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 stopped working

I have custom modes/renderers for my row and column headers. I added code to handle mouse events and now the selection of rows, columns, table, etc isn''t working and I can''t figure out why. The code I''ve added that causes it to break is as follows: protected override void OnMouseDown(int rowIndex, int colIndex, MouseEventArgs e) { base.OnMouseDown(rowIndex, colIndex, e); if (e.Button == MouseButtons.Left) { mouseDownCell_ = new Point(colIndex, RowIndex); mouseDown_ = true; this.Grid.InvalidateRange(GridRangeInfo.Cell(rowIndex, colIndex)); } } protected override void OnMouseUp(int rowIndex, int colIndex, MouseEventArgs e) { base.OnMouseUp(rowIndex, colIndex, e); if (mouseDown_ && e.Button == MouseButtons.Left) { mouseDown_ = false; this.Grid.InvalidateRange(GridRangeInfo.Cell(rowIndex, colIndex)); } } protected override void OnMouseMove(int rowIndex, int colIndex, MouseEventArgs e) { base.OnMouseMove(rowIndex, colIndex, e); if (mouseDown_) { if (mouseDownCell_ != new Point(colIndex, RowIndex)) { mouseDown_ = false; this.Grid.InvalidateRange(GridRangeInfo.Cell(rowIndex, colIndex)); } } } protected override int OnHitTest(int rowIndex, int colIndex, MouseEventArgs e, IMouseController controller) { if (controller != null && controller.Name == "OleDataSource") // other controllers have higher priority than me return 0; return 1; } If I comment out the code, everything works fine. What am I missing? Thanks

3 Replies

AD Administrator Syncfusion Team July 20, 2004 11:57 AM

When you return nonzero in OnHitTest, then no other mouse controller will get the mouse actions. So, the SelectCells controller will not get a chance to do anything. So, if you want the default behavior to take place you cannot return nonzero in OnHitTest. One possible solution would be to do all the processing you want to do from OnHitTest, and just return 0. You can test Control.MouseButtons to see if a particular button is pressed in OnHitTest.


AD Administrator Syncfusion Team July 20, 2004 12:13 PM

Oh, okay. So there''s no method to chain them together then or to pass the mouse events over to another controller?


AD Administrator Syncfusion Team July 20, 2004 12:47 PM

You can try code like this: Syncfusion.Windows.Forms.IMouseController selectController = this.grid.MouseControllerDispatcher.Find("DragSelect"); selectController.MouseDown(e); //call mousedown Now I haven''t actually tried this so I am not 100% sure it will work as you need things to work.

Loader.
Live Chat Icon For mobile
Up arrow icon