Package Maskedit Controls with ActiveX Control -> Solve the problem that cannot be bound

zhaozj2021-02-08  242

Package Maskedit Controls with ActiveX Control -> Solve the problem that cannot be bound

Lee_jvn@21cn.com OICQ: 37198873

Refer to the decision or change the universal ActiveX control.

(1) New ActiveX Control Project. Place a Maskedit control on. It sets the property reference: UserControl Name: DataDate. UserControl DataBindingBehavior Set 1-VVBSIMPLEBOUND MASKEDTBOX Name: mskdate.

(2). Add a data attribute is used to bind. The operation is as follows (I use it as a traditional system, it may be not the same as the way). Open the menu: gain set -> gain set administrator. Load Visual Basic AcitVex Control item Interface Elf and start. Run to: Establish a self-subscribed interface member Add a Property: DateValue (this property is the stuff for you to operate). Next Determination of correspondence: Put the properties in commonly used public projects The event is bound to MSKDATE. Such as MSKDate is unlocked, and can be bound to userControl. Set the DateValue's Data Type Set Date Type The above operation is completed.

(3). Set the data binding property of DateValue.

Click UserControl. Open the tool ---> Program properties. Select DateValue from the name field. Select the data link as follows: "Property Data Connection Function" "Before the attribute value changes, call canPropertyChange." Instant update "

At this point, DataValue has a data binding function. The properties of this control will increase in Dongdong, such as DataSource.Datafield.

(4). Write code. A. Set the control size.

. Private Sub UserControl_Resize () MskDate.Move 0, 0, UserControl.Width, usercontrol.Height End Sub b dateValue code will be amended as follows: Public Property Let DateValue (ByVal New_DateValue As Date) m_DateValue = New_DateValue PropertyChanged "DateValue" If Not IsEmpty (m_datevalue) Then if isdate (m_datevalue) Then if Year (m_datevalue)> 1970 Then Mskdate.text = format (m_datevalue, "yyyy / mm / dd") Else mskdate.text = "____ / __ / __" end if else mskdate .Text = "____ / __ / __" end if else mskdate.text = "____ / __ / __" end if End Property, this is to determine whether the value passed is required, if it is effective, it is displayed Otherwise, otherwise it is displayed in MSKDATE. Private sub mskdate_validate (Cancel As Boolean)

If IsDate (Trim (MskDate.Text)) Then If CanPropertyChange ( "DateValue") Then m_DateValue = CDate (MskDate.Text) PropertyChanged "DateValue" End IfElse MsgBox "Invalid date value!", VbExclamation, "Date Error!" If Not ISEMPTY (M_DateValue) Then IF Year (m_datevalue)> 1970 Then Mskdate.text = Format (m_datevalue, "YYYY / MM / DD") Else mskdate.text = "____ / __ / __" end if else MSKDATE.TEXT = "____ / __ / __" end if else mskdate.text = "____ / __ / __" end if end ifend sub

'This is the value of MSKDATE, and if it is valid, call PropertyChanged "DateValue". The data will change the value of the data field bound by DataField. Finally, the engineering is used as a control DataDate.ocx to reference, DataValue properties That is, the text attribute equivalent to Text can be called directly in the document. Use the above method to customize the data binding control for our special processing. Lee_jvn at 2001.02.15 OICQ: 37198873

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

New Post(0)