Click here to Skip to main content
15,920,438 members
Home / Discussions / C#
   

C#

 
GeneralRe: sp.net c# search function? add friend function? Pin
harold aptroot1-Jan-10 4:52
harold aptroot1-Jan-10 4:52 
QuestionShortened version of setting and getting properties Pin
Brendan Vogt1-Jan-10 3:50
Brendan Vogt1-Jan-10 3:50 
AnswerRe: Shortened version of setting and getting properties Pin
N a v a n e e t h1-Jan-10 4:02
N a v a n e e t h1-Jan-10 4:02 
GeneralRe: Shortened version of setting and getting properties Pin
Brendan Vogt1-Jan-10 9:29
Brendan Vogt1-Jan-10 9:29 
AnswerRe: Shortened version of setting and getting properties Pin
DaveyM691-Jan-10 5:14
professionalDaveyM691-Jan-10 5:14 
QuestionAXmediaplayer under Vis2008 Pin
electriac1-Jan-10 3:36
electriac1-Jan-10 3:36 
AnswerRe: AXmediaplayer under Vis2008 Pin
electriac1-Jan-10 4:38
electriac1-Jan-10 4:38 
Questionreporting issue Pin
mjawadkhatri1-Jan-10 0:19
mjawadkhatri1-Jan-10 0:19 
QuestionI have a problem setting paper size for printing a page Pin
Alex Manolescu31-Dec-09 23:10
Alex Manolescu31-Dec-09 23:10 
AnswerRe: I have a problem setting paper size for printing a page Pin
Mohammad Motealleh1-Jan-10 2:38
Mohammad Motealleh1-Jan-10 2:38 
GeneralRe: I have a problem setting paper size for printing a page Pin
Alex Manolescu1-Jan-10 6:59
Alex Manolescu1-Jan-10 6:59 
QuestionUser Control Question - Changing Location and Size Pin
Roger Wright31-Dec-09 21:34
professionalRoger Wright31-Dec-09 21:34 
AnswerRe: User Control Question - Changing Location and Size Pin
Rob Philpott31-Dec-09 22:26
Rob Philpott31-Dec-09 22:26 
GeneralRe: User Control Question - Changing Location and Size Pin
Roger Wright1-Jan-10 4:36
professionalRoger Wright1-Jan-10 4:36 
QuestionRe: User Control Question - Changing Location and Size Pin
Eric Dahlvang31-Dec-09 23:01
Eric Dahlvang31-Dec-09 23:01 
AnswerRe: User Control Question - Changing Location and Size Pin
Roger Wright1-Jan-10 4:33
professionalRoger Wright1-Jan-10 4:33 
GeneralRe: User Control Question - Changing Location and Size Pin
DaveyM691-Jan-10 5:10
professionalDaveyM691-Jan-10 5:10 
GeneralRe: User Control Question - Changing Location and Size Pin
Roger Wright1-Jan-10 22:06
professionalRoger Wright1-Jan-10 22:06 
GeneralRe: User Control Question - Changing Location and Size Pin
DaveyM692-Jan-10 2:59
professionalDaveyM692-Jan-10 2:59 
GeneralRe: User Control Question - Changing Location and Size Pin
Roger Wright2-Jan-10 5:17
professionalRoger Wright2-Jan-10 5:17 
AnswerRe: User Control Question - Changing Location and Size Pin
Nicholas Butler31-Dec-09 23:46
sitebuilderNicholas Butler31-Dec-09 23:46 
This will not work:

Size.Height = 100;
Size.Width = 100;

Location.X = 100;
Location.Y = 100;


This is because Size is a System.Drawing.Size and Location is a System.Drawing.Point. Both of these types are structs, which means that they are passed by value not by reference.

So when you write:

Size size = Size;
Point location = Location;


you are actually getting copies of the structs, not a reference to the original data.

This means it makes no sense to try to change, say the Height of the copy of the Control's Size and the compiler flags this as an error for you.

As Eric said, you can replace the underlying Size and Point like this:

Size = new Size( 100, 100 );
Location = new Point( 100, 100 );


This works because in the Control class, the properties have setters as well as getters:

partial class Control
{
  public Size Size { get; set; }
  public Point Location { get; set; }
}


Now, if you add new properties to your Control called Size and Location, they have no relation to the base class properties with the same names. The new properties just 'hide' the base class properties. The compiler warns you about doing this, as it is legal, although confusing and not recommended. You can add the new keyword to get rid of the warning, but this is also confusing and not recommended.

Nick

----------------------------------
Be excellent to each other Smile | :)

GeneralRe: User Control Question - Changing Location and Size Pin
Roger Wright1-Jan-10 4:25
professionalRoger Wright1-Jan-10 4:25 
AnswerRe: User Control Question - Changing Location and Size Pin
DaveyM6931-Dec-09 23:50
professionalDaveyM6931-Dec-09 23:50 
GeneralRe: User Control Question - Changing Location and Size Pin
Roger Wright1-Jan-10 4:28
professionalRoger Wright1-Jan-10 4:28 
Questionmultiple lines string Pin
Member 59031031-Dec-09 18:57
Member 59031031-Dec-09 18:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.