C# control question

I have created a movable picture box using the following code:

picBox.Location = new Point(x, 190);

Where x is a variable.

My question is this, why is it that you have to create a new Point class in order to change the location of the picture box. Is there no Get() or Set() functions. Also is Location a pointer to a Point class, and is the previous Point class deleted when the new class is assigned or is it left for garbage collection.

I also have another question. I discovered how to make a picture box move by studying the Tiny Tennis program starter kit. If I had been trying to figure this out on my own how would I have to go about it, in other words if a programmer was trying to figure this out or some other problem to complete some programming project for a company, how would he find this information I have had a real problem with obtaining this sort information.

I am sure that there must be some sort of logical method for finding answers to these sorts of questions. Please include an example of how one might do this effeciently if possible.

Any help on this is greatly appreciated.

Thanks,

CoderX

 

 

 



Answer this question

C# control question

  • Scott Cairney

    Hi,
     

    The quick way to get help is MSDN.

    For example you want to get information about Point in given below example , just put your cursor on the Point and press F1. MSDN will find every thing related to Point for you.


    new
    Point();


    MSDN will also show navigation where is Point from…

    MSDN Library > .NET Development > .NET Framework SDK > Class Library Reference > System.Drawing > Point Structure > Point Constructor


    More Point is a structure not a class so no new instance of class will be created, it will automatically set value of Top & Left.

    Hope this help.



  • Stephen Turton

    Thanks for your response James. This was a really technical question. This insite helps a lot.
  • mEmENT0m0RI

    Thanks Mubshir,

    Your reply was very helpful, but I have already explored the information on MSDN.

    I just seems to me that some programmers know exactly what method or feature to use to get C# to do excatly what they need it to do. I am just wondering if there is not some other source of information. You can find bits and pieces of code in books that make you think wow! how come I couldn't find that method.

    Does anyone know of any other reference material


  • Gary Miller

    This makes a lot of sense to me. Thanks for all the help Chris your insite is invaluable.

     


  • asi 96

  • Shapid

    >> is the previous Point class deleted when the new class is assigned or is it left for garbage collection.

    Basically, the latter, but there is really not much difference between the two options.



  • lpasquali

    You can access the Left and Top property of the PictureBox control to move it without instanciating Point object.



    picBox.Left = x;
    picBox.Top = 100;

     


    Regards,

    -chris

  • Jean Baronas

    Thanks Chris. This information is very helpful.

    I would still like to know if there is a quick way to find answers such as the Point class topic. There must be some kind of reference or something for a programmer to use.


  • nadim

    Well, most of us are using MSDN for our programming reference. The reason that some programmers knows the method better than the other is not because of reference, but because they've seen or used that method on some of their projects (with the exception that other members of this forums are the class designers themselves, so they know which method is for which purpose).

    The trick is actually the combination of experience and reference. Don't rush it, you'll eventually get better than some of us here.

    Cheers,

    -chris

  • Seungho Nam

    And by the way, most good programmers use working and tested source codes as their reference, and you can find working codes (with article) in most well known source code repository sites.

    My personal favorite:
    http://www.codeguru.com
    http://www.codeproject.com

    Regards,

    -chris

  • C# control question