[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 163
  • Last Modified:

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
0
Todd_Anderson
Asked:
Todd_Anderson
  • 3
  • 2
1 Solution
 
JackOfPHCommented:
Can you show us some codes?
0
 
Todd_AndersonAuthor Commented:
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
0
 
JackOfPHCommented:
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.
0
 
JackOfPHCommented:
Well try this:

Private m_Initialize as boolean = false

Private Sub FormConfigure_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated


'' *******check if the form was activated already.

If m_Initialize = false then



        '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()
       
'Set the buffer to true;
        m_initialize = true
end If
    End Sub

0
 
Todd_AndersonAuthor Commented:
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
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now