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

Edited 3 Years Ago by tinstaafl

Thanks

Please do reply on my datagrid view Combobox coloumn post

This question has already been answered. Start a new discussion instead.