Align center of node to grid rectangle

Hi,

I want when use moves the certain type of nodes i want to snap the center of node to center of grid rectangle. Some type of nodes user need to move freely. Can you suggest which event should i use after the node moves i want to adjust to center of grid rectangle.

Regards,

Venkatesh

Hi,

May be in my previous email it is not clear.

When add node object or move object we want to align center of node to center of grid like below picture

We don’t want to end up when the user move the node like below picture

Can you please suggest some ideas how to achieve this task.

This bit urgent because one our client is asking this feature.

Looks forwards for your help.

From the User Guide:

Grid snapping moves the Location of objects (when dragging) to a point in a grid cell. You can control which spot in the cell that is by setting the GridSnapCellSpot property.

so… you want to override Location on the node and return the icon.Center.

note you have to override by the get and set or things get weird.

so, it’s going to be something like this:

public override PointF Location {
  get { return this.Icon.Center; }
  set { this.Icon.Center = value; }
}

(assuming that “Icon” is that little blue dot.

RackGrid in Planogrammer shows how to override CanSnapPoint to snap some objects and not others.

Thanks for the help