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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

ExpandButton with different offsets for differet rows - does not work

Thread ID:

Created:

Updated:

Platform:

Replies:

33810 Aug 26,2005 11:22 AM UTC Aug 26,2005 01:11 PM UTC Windows Forms 1
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On August 26, 2005 11:22 AM UTC

Hello! I use grid of ver 1.6.1.8 I want my cell button, that I use instead of GridDataBoundRowExpandCellButton in GridDataBoundGrid, to have offset from the left of edge of column equal to N*(Level of hierarchy): I mean - I have DataSource with two levels, and expand buttons for level 2 must be situated not under expand button for level 1, but to be offseted to the right side. This helps to display tree-like organisation of levels in DataSource. Now Problem: I store offset for current cell in GridStyleInfo.tag and in method OnLayout of descedant of the GridDataBoundRowExpandCellRenderer change bound for current button: /// protected override Rectangle OnLayout(int rowIndex, int colIndex, GridStyleInfo style, Rectangle innerBounds, Rectangle[] buttonsBounds) { int tag = 0; if(style.Tag != null) tag = (int)style.Tag; int offset = 10*tag; Rectangle rect = Rectangle.FromLTRB(innerBounds.Left + offset,innerBounds.Top, innerBounds.Left + offset + 15, innerBounds.Bottom); buttonsBounds[0] = GridUtil.CenterInRect(rect , new Size(11,11)); innerBounds.Location = new Point(innerBounds.Location.X + offset + 15, innerBounds.Location.Y); innerBounds.Width -= (offset + 15); return innerBounds; } And buttons are drawn at their correct places, but when I try to click on them - only buttons of level 1 works properly. For nested levels click on button does not work, but click at part of the cell, that situated under the button of level 1 - works: I mean that buttons are drown offsetted but they work like they all are situated without offset at the most left side of the cell. Can you suggest something? Thank you

Administrator [Syncfusion]
Replied On August 26, 2005 01:11 PM UTC

I found solution: In case if someone will need it too: in my ExpandButton that derives from GridDataBoundRowExpandCellButton next methods were overrided: public override int HitTest(int rowIndex, int colIndex, MouseEventArgs e, IMouseController controller) { GridStyleInfo style = this.Grid.GetViewStyleInfo(rowIndex, colIndex, true); GridCellLayout layout = this.Owner.GetCellLayout(rowIndex, colIndex, style); int tag = 0; if(style.Tag != null) tag = (int)style.Tag; int offset = 10*tag; Rectangle withButton = Rectangle.FromLTRB(layout.CellRectangle.Left + offset, layout.CellRectangle.Top, layout.CellRectangle.Left + offset + 11, layout.CellRectangle.Bottom); if(withButton.Contains(e.X,e.Y)) { return GridHitTestContext.CellButtonElement; } return GridHitTestContext.None; } public override void MouseDown(MouseEventArgs e, GridCellHitTestInfo ht) { GridStyleInfo style = this.Grid.GetViewStyleInfo(ht.RowIndex, ht.ColIndex, true); GridCellLayout layout = this.Owner.GetCellLayout(ht.RowIndex, ht.ColIndex, style); int tag = 0; if(style.Tag != null) tag = (int)style.Tag; int offset = 10*tag; Rectangle buttonBounds = Rectangle.FromLTRB(layout.CellRectangle.Left + offset, layout.CellRectangle.Top, layout.CellRectangle.Left + offset + 11, layout.CellRectangle.Bottom); ht.CellButtonBounds = buttonBounds; base.MouseDown (e, ht); } public override void MouseUp(MouseEventArgs e, GridCellHitTestInfo ht) { GridStyleInfo style = this.Grid.GetViewStyleInfo(ht.RowIndex, ht.ColIndex, true); GridCellLayout layout = this.Owner.GetCellLayout(ht.RowIndex, ht.ColIndex, style); int tag = 0; if(style.Tag != null) tag = (int)style.Tag; int offset = 10*tag; Rectangle buttonBounds = Rectangle.FromLTRB(layout.CellRectangle.Left + offset, layout.CellRectangle.Top, layout.CellRectangle.Left + offset + 11, layout.CellRectangle.Bottom); ht.CellButtonBounds = buttonBounds; if (FireClickOnMouseUp && buttonBounds.Contains(new Point(e.X, e.Y))) OnClicked(new GridCellEventArgs(ht.RowIndex, ht.ColIndex)); this.SetMouseDown(ht, false); } Now it''s works - buttons have differet offset and they are working Thanks anyway

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;