___ ___ erkimt manage Multiple WindowsForm SplitContainer ______ qstntxt ___

I have multiple windowsforms inside a SplitContainer, one of them, I have a ListBox.

That is, outside the SplitContainer, on Form1, has button, when I click it, I want to add a text in the ListBox inside the SplitContainer on Form2

When I click the button, nothing happens! < Here is the error.

Form1Load:

%pre%

Button1code(ERRORishere):

%pre%    
______azszpr94312___

Of course it will not add, you are using %code% as if it were a static member, when re-creating the object with %code% will appear the item that you defined. It's like a pre-addition.

To solve this you should create a reference to the created member, follow the example below:

%pre%

To add the item to the ListBox, do the following:

%pre%     

___
0

I have multiple windowsforms inside a SplitContainer, one of them, I have a ListBox.

That is, outside the SplitContainer, on Form1, has button, when I click it, I want to add a text in the ListBox inside the SplitContainer on Form2

When I click the button, nothing happens! < Here is the error.

Form1Load:

PrivateSubform1_Load(senderAsObject,eAsEventArgs)HandlesMyBase.LoadDimform2addAsNewForm2form2add.TopLevel=FalseSplitContainer1.Panel2.Controls.Add(form2add)form2add.Show()Dimform3addAsNewForm3form3add.TopLevel=FalseSplitContainer1.Panel2.Controls.Add(form3add)form3add.Show()Dimform4addAsNewForm4form4add.TopLevel=FalseSplitContainer1.Panel2.Controls.Add(form4add)form4add.Show()EndSub

Button1code(ERRORishere):

Form2.ListBox1.Items.Add("Texto a ser adicionado")
    
asked by anonymous 23.10.2015 / 21:26

1 answer

1

Of course it will not add, you are using Form2.ListBox1.Items.Add as if it were a static member, when re-creating the object with Form2 will appear the item that you defined. It's like a pre-addition.

Tosolvethisyoushouldcreateareferencetothecreatedmember,followtheexamplebelow:

FriendWithEventsform2addAsFormPrivateSubform1_Load(senderAsObject,eAsEventArgs)HandlesMyBase.Loadform2add=NewForm2()'Criadoareferênciasemi-públicadoobjeto'form2add.TopLevel=FalseSplitContainer1.Panel2.Controls.Add(form2add)form2add.Show()...

ToaddtheitemtotheListBox,dothefollowing:

form2add.ListBox1.Items.Add("Texto a ser adicionado")
    
24.10.2015 / 00:04