Time Select Control 5 available to display null value 5

xiaoxiao2021-03-06  38

Private void TBDAY_KEYPRESS (Object Sender, System.Windows.Forms.KeypressEventArgs E)

{

IF (this.Designmode)

Return;

TextBox Obj = (TextBox) Sender;

Obj.selectedText = ""

String strign = Obj.Text.trim ();

INT ILEN = STRVALUE.TOSTOSTOSTRING ();

INT key = (int) (e.keychar);

Switch (key)

{

Case 48: // 0

Case 49: // 1

Case 50: // 2

Case 51: // 3

Case 52: // 4

Case 53: //5

Case 54: // 6

Case 55: // 7

Case 56: // 8

Case 57: // 9

IF (ilen == 0)

E.handled = false;

Else IF (ilen == 1) // has been entered

{

E.handled = true; / / The default is not processed, and the following analysis needs to be processed.

IF (key == 48 || key == 49 || key == 50) // Now type 0, 1, 2

{

IF (Obj.SelectionStart == 0) // Insert

{

IF (strValue! = "0") // is not 0

E.handled = false;

IF (strValue == "0" && (key == 49 || key == 50))

E.handled = false;

}

Else

{

IF (strValue == "0" || Strvalue == "1" || Strvalue == "2" | Strvalue == "3") // appended and has been entered 0, 1, 2, 3

E.handled = false;

IF (Key == 48 && Strvalue == "0")

e.handled = true;

IF (key == 50 && Strvalue == "3")

e.handled = true;

}

}

ELSE // Enter non-0, 1, 2 numbers

{

IF (Strvalue == "0" || Strvalue == "1" || Strvalue == "2") // has entered a 0, 1, 2

{

IF (Obj.SelectionStart == 0) // Insert a number front

{

IF (Key == 51 && Strvalue! = "2") // can only insert 3

E.handled = false;

}

Else

E.handled = false;

}

}

}

Else

e.handled = true;

Break;

Case 45: //

e.handled = true;

Break;

Case 8: // backss

IF (ilen == 0)

Obj.Parent.selectNextControl (Obj, False, True, False, true); Break;

Case 27: // ESC

E.handled = false;

Break;

DEFAULT:

e.handled = true;

Break;

}

}

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

{

IF (this.Designmode)

Return;

TextBox Obj = (TextBox) Sender;

Obj.selectall ();

}

Private void TBMONTH_KEYDOWN (Object Sender, System.Windows E)

{

IF (this.Designmode)

Return;

TextBox Obj = (TextBox) Sender;

INT IVALUE = E.KEYVALUE;

Switch (iValue)

{

Case 37: // Left

IF (Obj.SelectionStart == 0)

{

Obj.Parent.selectNextControl (Obj, False, True, False, true);

}

Break;

Case 38: // TOP

Incdecdate (1);

Break;

Case 39: // Right

IF (Obj.SelectionStart == Obj.Text.length)

{

Obj.Parent.selectNextControl (Obj, true, true, false, true);

}

Break;

Case 40: // down

Incdecdate (-1);

Break;

}

}

Private Void DateInput_leave (Object Sender, System.EventArgs E)

{

SETRIGHTFMT ();

}

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

{

String stringear = tbyear.text;

INT ILEN = strength;

Switch (Ilen)

{

Case 0:

Break;

Case 1:

Tbyear.Text = "200" strYear;

Break;

Case 2:

IF (int.Parse (Stryear) <40)

TBYear.Text = "20" strYear;

Else

Tbyear.Text = "19" strYear;

Break;

}

}

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

{

IF (tbmonth.text! = "" && tbday.text! = "")

Setrightmonthday ();

}

Private void updown_scroll (Object Sender, System.Windows.Forms.Scrolleventargs E)

{

IF (this.Designmode)

Return;

Switch (E.TYPE)

{

Case scrolleventtype.smallincrement:

Incdecdate (-1);

Break;

Case ScrolleventType.smallDecrement: incdecdate (1);

Break;

}

}

Private void btnmain_paint (Object Sender, System.Windows E)

{

Control con = (control) Sender;

Int baselen = con?height / 6;

Point Pos1 = New Point (Con. Width / 2 - Baselen-2, Baselen * 2);

POINT POS2 = New Point (Con. Width / 2 Baselen 2, Baselen * 2);

Point POS3 = New Point (con.width / 2, baselen * 4);

Point [] Mulpos = {POS1, POS2, POS3};

IF (btnmain.enabled)

{

E.Graphics.drawPolygon (Pens.Black, Mulpos);

E.Graphics.FillPolygon (brushes.black, mulpos);

}

Else

{

E.Graphics.drawPolygon (Pens.Darkgray, Mulpos);

E.Graphics.FillPolygon (Brushes.darkgray, Mulpos);

}

}

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

{

IF (this.Designmode)

Return;

FRMCALENDAR.Visible

{

FRMCALENDAR.VISIBLE = FALSE;

Return;

}

Else

{

Point pos = this.location;

POS.Y = POS.Y THISHEIGHT;

POS = this.parent.pointtoscreen (POS);

POS = SetCalendarpos (POS, FRMCALENDAR);

FRMCALENDAR.SETDESKTOPLOCATION (POS.X, POS.Y);

FRMCALENDAR.Visible = True;

}

}

Private Point SetCalendarpos (Point Spos, Control Contoshow)

{

Point newpos = new point (spos.x, spos.y);

INT iconwidth = contoshow.width;

INT iconheight = contShow.height;

Int iscrwidth = system.windows.Forms.Screen.primaryScreen.WorkingArea.width;

Int iscrheight = system.windows.Forms.Screen.primaryScreen.workingarea.height;

IF (spos.y iconheight> iscrheight)

Newpos.y = iscribhip - iconheight;

IF (spos.x iconwidth> iscrwidth)

NewPos.x = iscrwidth - iconwidth;

Return newpos;

}

Private Void Lbspace_Click (Object Sender, System.Eventargs E)

{

IF (this.Designmode) return;

TBDAY.FOCUS ();

TBDAY.SelectAll ();

}

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

{

Label label = (label) Sender;

Label.enabled)

Label.BackColor = color.fromknowncolor (knowncolor.window);

Else

Label.BackColor = color.fromknowncolor (knowncolor.control);

}

} // End Class

Public class dateformatconverter: system.componentmodel.stringconverter

{

///

/ / / Determine if the drop-down frame is determined according to the return value

///

///

/// true: The form of the pull-down box

/// false: the form of ordinary text editing

///

Public override Bool GetStandardValuessupported (System.comPonentmodel.ityped Context)

{

Return True;

}

///

/// Down-pull box specific content

///

Public override system.componentmodel.typeconverter.standardvaluescollection getStandardValues ​​(System.comPonentModel.ityped "criptorContext Context)

{

Return New StandardValuesCollection (New String [] {"YYYY-MM-DD", "YYYY.MM.DD", "YYYY / MM / DD", "YYYY MM Month Day", "Custom"});

}

Public override Bool CanconvertFrom (System.comPonentModel.ityped, System.Type SourceType)

{

IF (SourceType == TypeOf (String))

Return True;

Else

Return Base.canconvertFrom (Context, SourceType);

}

///

// / Determine if it is an in -rable text box according to the return value

///

///

/// true: Text box cannot be edited

/// Flase: Text box can be edited

///

Public Override Bool GetStandardValuesexClusive (System.comPonentModel.ityped Context)

{

Return True;

}

}

} // end namespace

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

New Post(0)