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

Grid- Treecell

Hi I have a sync grid in my form with one column as TreeCell. ( CellType="TreeCell") It is a custom cell type. I am getting the records in tree structure with ( + and - Sign). But when I start the selection from the column which has treecell type, I could not. But selection is working if it starts from other non tree column. Please find attached the screen shot and description in word document. PS: Selection - Holding the right mouse button and dragging.

TreeCell.zip

8 Replies

RR Ravichandran Raman February 27, 2006 03:07 PM UTC

Hi any one pls help me >Hi > >I have a sync grid in my form with one column as TreeCell. ( CellType="TreeCell") It is a custom cell type. I am getting the records in tree structure with ( + and - Sign). > But when I start the selection from the column which has treecell type, I could not. >But selection is working if it starts from other non tree column. > >Please find attached the screen shot and description in word document. > >PS: Selection - Holding the right mouse button and dragging.

TreeCell.zip


ST stanleyj Syncfusion Team February 27, 2006 03:16 PM UTC

Hi RaviChandran, You can then have the row header by modifying the QueryColWidth handler to make selections by dragging the rowheader. void GridQueryColWidth(object sender, GridRowColSizeEventArgs e) { if( e.Index == 1) e.Size = 200; else if (e.Index > 0) e.Size = 100; else e.Size = 30; e.Handled = true; } Best regards, Stanley


RR Ravichandran Raman February 27, 2006 04:05 PM UTC

Hi Stanley, Thanks. But I dont want to my selection from header. Anywhere from the mid of the grid data but starts with the column which has tree node. But if I start the selection from next col (non tree col) then I could. Once I click on tree cell col and hold the right mouse button no selection happens. Regards Ravi >Hi RaviChandran, > >You can then have the row header by modifying the QueryColWidth handler to make selections by dragging the rowheader. > > void GridQueryColWidth(object sender, GridRowColSizeEventArgs e) > { > if( e.Index == 1) > e.Size = 200; > else if (e.Index > 0) > e.Size = 100; > else > e.Size = 30; > > e.Handled = true; > } > > >Best regards, >Stanley


ST stanleyj Syncfusion Team February 28, 2006 06:48 AM UTC

Hi Ravi, You would have noticed how the +/- expands and collapses, though they are not cell buttons and have no specific events to be raised. Let me explain you little further, to help you understand why selecting a range was not possible to start with that TreeCell column. Mouse messages (OnMouseDown, OnMouseHover, OnMouseUp) are being called for the cell renderer because non-zero return value of OnHitTest if requested handles the mouse event, zero return does not handle the mouse events. In our customized cell type the ContextMenu and call to ClickTreeNode which acts like CellButtonClick are coded in MouseDown. Therefore it is important to have a non zero return in the OnHitTest overrides to have the ContextMenu and the responces to the MouseDown over the images. If the ContextMenu is really not needed and if you feel that is fine to expand and collapse only with the left mouse button, then Change this code to have selections with right mouse button. protected override int OnHitTest(int rowIndex, int colIndex, MouseEventArgs e, IMouseController controller) { if(e.Button == MouseButtons.Left ) { //return a cell hit so OnMouseDown will be called later return GridHitTestContext.Cell; } else return 0; } Best regards, Stanley


RR Ravichandran Raman February 28, 2006 01:15 PM UTC

Hi Stanley, Thanks.I tried with the code piece you sent even that could not help me to start the selection from tree view col. Is there any other way to acheive pls let me know. I want the data in the grid has to be selected using normal selection ( how we do in word or text doc, by holding the right mouse button from the tree col) Thanks, Ravi. >Hi Ravi, > >You would have noticed how the +/- expands and collapses, though they are not cell buttons and have no specific events to be raised. Let me explain you little further, to help you understand why selecting a range was not possible to start with that TreeCell column. > >Mouse messages (OnMouseDown, OnMouseHover, OnMouseUp) are being called for the cell renderer because non-zero return value of OnHitTest if requested handles the mouse event, zero return does not handle the mouse events. > >In our customized cell type the ContextMenu and call to ClickTreeNode which acts like CellButtonClick are coded in MouseDown. Therefore it is important to have a non zero return in the OnHitTest overrides to have the ContextMenu and the responces to the MouseDown over the images. > >If the ContextMenu is really not needed and if you feel that is fine to expand and collapse only with the left mouse button, then Change this code to have selections with right mouse button. > > protected override int OnHitTest(int rowIndex, int colIndex, MouseEventArgs e, IMouseController controller) > { > if(e.Button == MouseButtons.Left ) > { > //return a cell hit so OnMouseDown will be called later > return GridHitTestContext.Cell; > } > else > return 0; > } > > >Best regards, >Stanley


ST stanleyj Syncfusion Team February 28, 2006 02:13 PM UTC

Hi Ravi, Please take a look to the modified sample. Holding the right mouse button and dragging from the TreeCell column works to me. I do not know other way now, will let you know if there are other possibilities. Best regards, Stanley


RR Ravichandran Raman March 1, 2006 11:34 AM UTC

Hi Stanley, Your sample code is working fine. But if I use right mouse button instead of left mouse button (my original requirement is right mouse button only), I could not able to expand the tree view and grid_SaveCellInfo() event is not being fired which is actually used to expand the node the node. In your example also if you change the button to Right on OnHitTest event. You could not close the tree view. thanks and awaiting for your reply Ravi >Hi Ravi, > >Please take a look to the modified sample. Holding the right mouse button and dragging from the TreeCell column works to me. > >I do not know other way now, will let you know if there are other possibilities. > >Best regards, >Stanley


ST stanleyj Syncfusion Team March 8, 2006 11:10 AM UTC

Hi Ravi, Sorry for the delay, please try checking this condition to get the cells selected from the TreeView cell. protected override int OnHitTest(int rowIndex, int colIndex, MouseEventArgs e, IMouseController controller) { if (e.X < 50) if (e.Button != MouseButtons.None) return GridHitTestContext.Cell; return 0; } This conditions helps for the selection while e.X > 50, hoping button like images are less than 50. Hope this might help at some point. Best regards, Stanley

Loader.
Live Chat Icon For mobile
Up arrow icon