How can I change the Cursor based on clickable country?

2 posts, 0 answers
  1. Bing
    Bing avatar
    3 posts
    Member since:
    Jul 2012

    Posted 21 Aug 2011 Link to this post

    Hi Guys

    I need change the Cursor based on each countries information. How can I do it?

    Thanks in advance
    Bing
  2. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 24 Aug 2011 Link to this post

    Hello Bing,

    You can use the MouseEnter and MouseLeave events of the map shape object and shape's extended data. For example:

    polygon.MouseEnter += new MouseEventHandler(this.ShapeMouseEnter);
    polygon.MouseLeave += new MouseEventHandler(this.ShapeMouseLeave);
     
    private Cursor oldCursor;
     
    private void ShapeMouseEnter(object sender, MouseEventArgs e)
    {
        MapShape shape = sender as MapShape;
        if (shape != null)
        {
            ExtendedData data = shape.ExtendedData;
            if ((string)data.GetValue("Name") == "USA")
            {
                oldCursor = this.Cursor;
                this.Cursor = Cursors.Hand;
            }
        }
    }
     
    private void ShapeMouseLeave(object sender, MouseEventArgs e)
    {
        MapShape shape = sender as MapShape;
        if (shape != null)
        {
            this.Cursor = oldCursor;
        }
    }

    Greetings,
    Andrey Murzov
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  3. DevCraft banner
Back to Top