Results 1 to 6 of 6

Thread: Form_Load event: how to use??

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2003
    Location
    Europe, Belgium
    Posts
    84

    Lightbulb Form_Load event: how to use??

    Hi,

    I have a form that is used to enter data in a database (MSAccess).
    In this form the user can select different listboxes and comboboxes and the selected values are then written to the underlying database after the user has clicked the 'update'-button.

    Everything works fine, but I would like to 'refresh' the form to it's original state as it was loaded after the first startup. I don't know how to do this. I tried to call the form_load event because this contains all the initialisations, but it doesn't work.

    Can anybody help me with this? Please give me a code example is possible.

    Many thanks,

    Tom

  2. #2
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    you need to reset each control back to the original state. You could make a routine that does that and when the user has made the final selection, call the routine in that control's event.

    like this:

    text1.text = ""
    combobox1.text = ""
    label1.text = "ready for another entry"

    get it?

    you just need to manually set them back like that.

    It's a good idea to use a routine because that way, the user could select a button and force things back to default if he wanted to.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2003
    Location
    Europe, Belgium
    Posts
    84
    Thanks Andy,

    I wrote a sub with your suggestions in it. They work fine for a combobox and a textbox but not for a listbox because the listbox should show the default startup values. How can I do this.

    PS: refreshing the form with me.refresh doesn't do the job.

    Thanks

    Tom

  4. #4
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    They work fine for a combobox and a textbox but not for a listbox because the listbox should show the default startup values. How can I do this.
    By clearing it
    ListBox1.Items.Clear()
    and repopulating it the same way you did in the Form Load
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Oct 2003
    Location
    Europe, Belgium
    Posts
    84
    Thanks,

    I'll give it a try.

    Tom

  6. #6
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    here's some code I found at VBExplorer.com

    Code:
    Public Sub ClearAllText(frm As Form, ctl As Control)
    
    For Each ctl In frm
            If TypeOf ctl Is TextBox Then
                    ctl.Text=""
            End If
    Next ctl
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width