Possible Duplicate:
Update label location in C#?
I am creating a custom windows form and when trying to change the location of the label I get the error:Error 1 Non-invocable member ‘System.Windows.Forms.Control.Location’ cannot be used like a method. C:\Users\Ran\Documents\Visual Studio 2010\Projects\SyncCustomForm\SyncCustomForm\SyncControl1.cs 50 24 SyncCustomForm
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace SyncCustomForm
{
public partial class SyncControl : UserControl
{
public SyncControl()
{
InitializeComponent();
}
public ProgressBar prbSyncProgress
{
get { return prbProgress; }
}
public Label lblException
{
get { return lblMessage; }
}
public Label lblStatus
{
get { return lblS; }
}
public Button btnPause
{
get { return btnP; }
}
public Button btnStop
{
get { return btnS; }
}
public GroupBox grbxSync
{
get { return gbxSync; }
}
private void SyncControl_Load(object sender, EventArgs e)
{
lblMessage.Location.X = 50;
}
}
}
The
Locationproperty is a struct andXis a property of that structure, and in this case you cannot set the value ofXindependently.You need to do this:
or if you want to set only X value, set the Left property:
You can only set properties of structs if you have a direct reference to that struct: