When / Where to initialize Controls on a Form

Giganews Newsgroups
Subject: When / Where to initialize Controls on a Form
Posted by:  brzak (brza…@gmail.com)
Date: Thu, 23 Oct 2008

I want to populate a two controls on a form at startup and i'm unsure
as to when / where to do this.

I want to:
  - populate a combobox with the options 1 to 5 (1,2,3,4,5)
  - set the first radio button to true, second to false.

I think the problem is me coming from a VBA background, I was looking
for the equivalent of a Form Initilaize / Load event, but of course it
doesn't exist.

i tried to put it in the code in the designer.vb code, which worked
great, but of course when I altered the design of the form, in Design
view, this was all wiped.

The code I want to insert is:

        Dim SourceItems(0 To 4) As String
        SourceItems = Split("1 2 3 4 5"," ")
        Me.ComboBox_IndentationLevel.Items.AddRange(SourceItems)
        Me.ComboBox_IndentationLevel.SelectedItem = 3

        '  I'm assuming these next two lines won't
        '    trigger the "RadioButton1_CheckedChanged" event
        Me.RadioButton1_Tab.Checked = True
        Me.RadioButton2_Space.Checked = False

Advice on where exactly this should go would be much appreciated [and
if there's a better way of doing this].

Thanks

Replies