Mapping a set of spatial coordinates

Posted on 2006-04-22
Last Modified: 2010-04-16
I have a simple forms program with a form that is 777 x 777, the program passes along 3 values from the previous form to 3 labels  XCoord, YCoord, and ZCoord.

What I AM trying to do is map on the form with a simple blue point 5px by 5px where exactly the point space is.

This is the code that is being used currently to pass the values to labels on the new form.

shw.XCoord.Text = "XCoord: " + coordX.ToString();
shw.YCoord.Text = "YCoord: " + coordY.ToString();
shw.ZCoord.Text = "ZCoord: " + coordZ.ToString();

Any help would be greatly appreiciated.


Question by:schenkp
    1 Comment
    LVL 5

    Accepted Solution

    First of all I would create a function on the form with the labels that sets the labels text.
    Also create a form paint handler to draw the blue point on the form (not sure how you wannt to handle the zcoord).
    This might look like:

    ///Global Vars to store where to paint the blue point
    int xcoord,ycoord,zcoord = -5;

    public void setCoord(int x int y, int z)
        //Set Label Text
        this.XCoord.text = x.ToString();
        this.YCoord.text = y.ToString();
        this.ZCoord.text = z.ToString();

        //Set global vars used to paint blue point
        xcoord = x;
        ycoord = y;
        zcoord = z;

    //Form Paint Event Handler
    void MyFormPaint(object sender, System.Windows.Forms.PaintEventArgs e)
        //Draw Blue Point on form canvas
        this.CreateGraphics().FillRectangle(new SolidBrush(Color.Blue),new Rectangle(xcoord,ycoord,5,5));

    Now from your other form call the setCoord function. EXAMPLE:


    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    This video discusses moving either the default database or any database to a new volume.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now