Tom Knowlton
asked on
user control - public property
Been away from Windows Form Controls dev for a while.
I have a control that displays the date and time in a label.
I want to create a property that is visible in the visual studio "Properties" window, such that I can grab the current contents of the label any time I want to.
I think attributes are used, but I don't remember how to do it.
Thanks, and please include small 'hello world" sample C# code for me.
I have a control that displays the date and time in a label.
I want to create a property that is visible in the visual studio "Properties" window, such that I can grab the current contents of the label any time I want to.
I think attributes are used, but I don't remember how to do it.
Thanks, and please include small 'hello world" sample C# code for me.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
My interim solution:
namespace DateTimeControl
{
public partial class UserControlDateTime: UserControl
{
public UserControlDateTime()
{
InitializeComponent();
}
[Description("DateTime displayed by the label"), Category("Data")]
public string LabelDateTimeText
{
get { return labelDateTime.Text; }
}
private void timerTick_Tick(object sender, EventArgs e)
{
DateTime dt = new DateTime();
dt = DateTime.Now;
labelDateTime.Text = dt.ToLongDateString() + " " + dt.ToLongTimeString();
}
}
ASKER