Link to home
Start Free TrialLog in
Avatar of Todd_Anderson
Todd_Anderson

asked on

What form event will do what I need?

VS 2005
VB

I have a form that I need to do certain things to when the user opens it.  Once it is open one of the things a user can do from this form is pick a file using the standard file picker.

I am currently using the  Activate event for the form to do the things that I needed to do at the begining.  It was working great.  Now that I have added the file picker I am having problem since Activate is firing when the user closes the file picker.  The forms Load event wasn't working for me (it seemed like the controls were not ready for what I needed to do).

Is there an event that does what I am looking for?

Thanks,

Todd
Avatar of JackOfPH
JackOfPH
Flag of Philippines image

Can you show us some codes?
Avatar of Todd_Anderson
Todd_Anderson

ASKER

The first sub below is what I want to do when the user opens the form.  The second is what happens when the user picks a file.  I don't want the first one to fire when the user is done picking a file.    

Private Sub FormConfigure_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
        'Fill the password text boxes since they are not bound to anything because of the encryption.
        TextBoxDatabasePassword.Text = Decrypt(My.Settings.DatabasePassword)
        TextBoxFTPPassword.Text = Decrypt(My.Settings.FTPPassword)

        'Select the first tab and the text in the first text field
        TabControlConfigure.SelectedTab = TabPageRetailer

        Me.TextBoxRetailerNumber.Focus()
        Me.TextBoxRetailerNumber.SelectAll()
    End Sub

    Private Sub ButtonDatabaseName_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonDatabaseName.Click
        'Let the user pick the database file for their POS system
        OpenFileDialogDatabaseName.Title = "Locate the database file"
        OpenFileDialogDatabaseName.ShowDialog()
        TextBoxDatabaseName.Text = OpenFileDialogDatabaseName.FileName

        'Add a tool tip to the database name textbox
        ToolTipConfigure.SetToolTip(TextBoxDatabaseName, OpenFileDialogDatabaseName.FileName)
    End Sub
I think it is better to put this in the form_load()

Did you try putting it, at the end of the form load?

If error occurs, Please post the error.
ASKER CERTIFIED SOLUTION
Avatar of JackOfPH
JackOfPH
Flag of Philippines image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
JackOfPH,

Your idea works great.  I'm a little dissapointed that I couldn't get it figured out using an event but I'll get over it.

Thanks,

Todd