interaction between forms
hi,
i'm very new at .net and programming, kind of a hobby :-)
i have 2 forms:
a head form that has 3 listboxes and a button (the 3 listboxes load text from 3 text files)
a 'pop up' form that has 3 listboxes, 3 textboxes and 3 buttons
when i click the button on the head form the 'pop up' form pops up.
the 3 listboxes on the 'pop up' form are linked to those on the head form.
i added 3 button on the 'pop up' form:
an add button (which adds an item to the listbox via textbox)
a remove button (which removes a selected item of the listbox)
a clear all button (which clears all items of all listboxes)
each button also has a <me.close> so that the 'pop up' form closes again
everything works perfectly so far!
but now:
when i add an item to the listbox it appears, when i add another it appears also perfectly
when i remove an item it gets removed,
BUT then when i add another item i have a blank line first and then the item in my listbox on the head form!!
code of the pop up form (head form = form1):
Code:
'remove button':
Private Sub Remove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For i As Integer = 0 To ListBox1.Items.Count - 1
Next
ListBox1.Items.Remove(ListBox1.SelectedItem)
Form1.ListBox1.Items.Clear()
Form1.ListBox1.Items.AddRange(ListBox1.Items)
Me.Close()
End Sub
'add button':
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
For i As Integer = 0 To ListBox1.Items.Count - 1
Next
ListBox1.Items.Add(TextBox1.Text)
Form1.ListBox1.Items.Clear()
Form1.ListBox1.Items.AddRange(ListBox1.Items)
Me.Close()
End Sub
can anyone please help this newbie?
thx,
Eshaidu