Making a simple date time clock UserControl ....

xiaoxiao2021-03-06  14

Using system;

Using system.collections;

Using system.componentmodel;

Using system.drawing;

Using system.data;

Using system.windows.forms;

Using my_diarys;

Namespace my_dialesss.userControls

{

///

/// summary description for xsysdatetime.

///

Public class xsysdatetime: system.windows.Forms.userControl

{

Private Xuicontrols.xLabel LBL_SYSDATETIME;

Private system.windows.Forms.timer Timer;

Private system.componentmodel.icontainer components;

Public xsysdatetime ()

{

// this call is required by the Windows.Forms Form Designer.

InitializationComponent ();

// Todo: add anyinitization after the initializecomponent call

}

///

/// Clean Up Any Resources Being Used.

///

Protected Override Void Dispose (Bool Disposing)

{

IF (Disposing)

{

IF (Components! = NULL)

{

Components.dispose ();

}

}

Base.dispose (Disposing);

}

#Region Component Designer Generated Code

///

/// Required Method for Designer Support - Do Not Modify

/// The contents of this method with the code editor.

///

Private vidinitiRizeComponent ()

{

This.Components = new system.componentmodel.container ();

THIS.LBL_SYSDATETIME = New Xuicontrols.xlabel ();

This.Timer = new system.windows.forms.timer (this.components);

THIS.SUSPENDLAYOUT ();

//

// LBL_SYSDATETIME

//

This.lbl_sysdatetime.borderstyle = system.windows.Forms.Borderstyle.fixed3d;

THISLBL_SYSDATETIME.FONT = New System.drawing.Font ("Microsoft Sans Serif", 9F, System.drawing.FontStyle.Regular, System.drawing.GraphicsUnit.Point, ((System.byte) (0)));

THIS.LBL_SYSDATETIME.LOCATION = New System.drawing.Point (0, 0);

THIS.LBL_SYSDATETIME.NAME = "lbl_sysdatetime"; this.lbl_sysdatetime.size = new system.drawing.size (170, 24);

This.lbl_sysdatetime.tabindex = 0;

This.lbl_sysdatetime.textalign = system.drawing.contentAlignment.middleleleft;

//

// Timer

//

This.Timer.Tick = new system.eventhandler (this.timer_tick);

//

// xsysdatetime

//

This.Controls.add (this.lbl_sysdatetime);

THIS.NAME = "xsysdatetime";

This.size = new system.drawing.size (172, 28);

This.Load = New System.EventHandler (this.xsysdatetime_load);

This.ResumeLayout (false);

}

#ndregion

Private void xsysdatetime_load (Object Sender, System.Eventargs E)

{

this.timer.start (); /// Remote operation

// sysdatetime ();

}

// private void sysdatetime ()

// {

// this.timer.Interval = 1000;

// this.lbl_sysdatetime.text = datetime.now.tostring ();

//}

Private void Timer_Tick (Object Sender, System.EventArgs E)

{

this.timer.Interval = 1000; // Refers to secondary unit

THIS.LBL_SYSDATETIME.TEXT = DATETIME.NOW.TOSTRING ("YYYY Year MM YY YY HH: MM: SS");

}

}

}

Rendering:

转载请注明原文地址:https://www.9cbs.com/read-48292.html

New Post(0)