Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Event Load Alternative?

Posted on 2005-04-26
5
Medium Priority
?
213 Views
Last Modified: 2010-04-23
I am running an ActiveX control a 3rd party company created, that seems to "disable" all my load events such as little things like this:

Dim displayString As String
        displayString = Format(strdate, "MM/dd/yyyy")
        txtEntryDate.Text = displayString

Is there an alternative to the "Load" event to have things execute when the form opens other than the typical event?
0
Comment
Question by:chrisryhal
  • 2
  • 2
5 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 13872184
What do you mean by "Load" event?  Is this code in the Form_Load event, and it doesn't get run?

Bob
0
 
LVL 9

Expert Comment

by:checoo
ID: 13872986
you can add the lines in the form constructor after the call to InitializeComponent()
0
 
LVL 2

Author Comment

by:chrisryhal
ID: 13875355
TheLearnedOne:  Yes, that is correct.  It seems that the ActiveX control allows everything to run BUT things in Form_Load.

Checoo:  could you show me a fast example?
0
 
LVL 9

Accepted Solution

by:
checoo earned 2000 total points
ID: 13882440
when you create a new form the VS IDE will generate the following code --

in sub new you will see a comment "Add any initialization after the InitializeComponent() call"
you can write your code there.

Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

        Dim displayString As String
        displayString = Format(strdate, "MM/dd/yyyy")
        txtEntryDate.Text = displayString

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        components = New System.ComponentModel.Container()
        Me.Text = "Form1"
    End Sub

#End Region

End Class
0
 
LVL 2

Author Comment

by:chrisryhal
ID: 13910187
checoo:

Your suggestion worked.  I am always learning new things every day, thanks to you experts.  Thanks again.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Integration Management Part 2
Screencast - Getting to Know the Pipeline
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question