Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"InitProperties" and "UserMode" analogues in VB.NET

Status
Not open for further replies.

andrey

Programmer
Jun 23, 2000
24
IL
Hi all!
If somebody has developed any user control (former ActiveX) in VB.NET yet - what are the .NET analogues for "InitProperties" and "UserMode" from VB6? In other words, how can I determine when control has been placed on it's container for the first time, what mode control is - design or runtime?

Thanks for advance
 
There is no Init_Properties because there are now variable initializers. Use Me.DesignMode for knowing design time.

If you want to know the first time, try a Private property initialized to True. When it is next loaded. the initializer will be executed but then VB uses Reflection and the Set accessor to set the persisted value.

I have not actually used this because I do no care about "first time", only DesignMode.

Private mDesign1st As Boolean = True
Private Property Design1st() As Boolean
Get
Return mDesign1st
End Get
Set(ByVal Value As Boolean)
mDesign1st = Value
End Set
End Property

Private Sub VBResizerTabber_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Me.DesignMode = True AndAlso _
mDesign1st = True Then
SetDesign1stTimeParms()
mDesign1st = False
end if
End Sub

Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Thank you!
I have one more question - if I set e.Handled = True in KeyPress event, it works correctly, but in KeyDown it just does not work. What is it - bug, issue or any new feature? I tried it on Windows XP SP1 and .NET SP1.
 
It is not a bug.
Found by searching KB on MSDN using KEY HANDLED.

"CAUSE
The KeyDown event is not designed to handle alphanumeric keystrokes. Although the KeyDown event fires when an alphanumeric key is pressed, you can only use the KeyDown event to determine information about what key was pressed. This event does not stop an alphanumeric keystroke from being processed.

Non-alphanumeric keystrokes (such as the arrow keys, the HOME key, the END key, and the DELETE key) can be handled during the KeyDown event."

Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top