I have created custom text box for specific purpose i.e to accept alphanumeric values only and the length of text should be 6. If the user put less than six characters the code in below block converts it to 6 characters by filling in zeros .

‘Custom Clss block
Protected Overrides Sub OnLostFocus(ByVal e As System.EventArgs)
‘some code
End sub 

Also i write code for LostFocus in in form code

‘Form class block
Private Sub TxtPurchasePLCode_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TxtPurchasePLCode.LostFocus

‘some code
End sub

**
Now the problem is code written on form class block get triggered before code in Custom Clss block
How can i make Custom Clss block Trigger before form class
**

Put the event handler in your class using the handles clause.

Private Overloads Sub Me_LostFocusByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LostFocus

In your form have another event handler without the handles clause, use the addhandler statement instead. The one with the handles clause should run first

AddHandler TxtPurchasePLCode.LostFocus, AddressOf TxtPurchasePLCode_LostFocus

Private Sub TxtPurchasePLCode_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs)
    ‘some code
End sub

Thanks

Please do reply on my datagrid view Combobox coloumn post

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.