Solved

VB.NET Control Array Help

Posted on 2004-10-08
4
162 Views
Last Modified: 2010-04-23
I used the following Microsoft article to create a control array:

http://msdn.microsoft.com/library/default.asp?url=/library/en us/dv_vstechart/html/vbtchcreatingcontrolarraysinvisualbasicnetvisualcnet.asp

I modified it to have a row of labels and one button to display some information on a summary form. My form has 2 tabs. it loads up to the first tab and builds the summary adding how many rows to the array i need. I want the user to be able to click the button I added for each row and have the program show the other tab. The way the article sets it up, the event handlers for the array are in my SummaryArray class. How do i get the event handler in the class to control my form or how do I get a function on my form to handle events for the SummaryArray class?
0
Comment
Question by:m9s999
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 19

Expert Comment

by:arif_eqbal
ID: 12274009
The link you posted is not opening
I think you need to Use AddHandler
Can you elaborate what exactly you want

0
 

Author Comment

by:m9s999
ID: 12275544
Lets try the link again.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchCreatingControlArraysInVisualBasicNETVisualCNET.asp?_r=1


The article uses AddHandler in the array class. I have that working. What i need is for the handler to do stuff on my parent form (switch tabs, load detail information).
0
 
LVL 19

Accepted Solution

by:
arif_eqbal earned 500 total points
ID: 12284851
See if you have the code already done and working and you do not want to mess with it All you can do is pass a reference of the Parent form to the class so that the event Handlers and other methods in the class can access the controls etc. of the Parent form.

In case you want to do this then create a public Variable in the Class
Public ParentForm as Form

then from the Parent Form when you create an instance of the class set ClassObject.ParenForm=me

Now you can use the ParentForm variable in the Class to modify/access the Parent form data/methods etc.

better still you make the ParentForm variable private and set it through a property or in Class Constructor.

Now another method is What I feel is you need not have the new class at all, In the same form you can add as many controls. But it will depend upon your exact equirement. In case you have a Form where you want to Add a few controls Dynamically and handle their events, you can procedd as follows:

Add a function in the Form

Private Sub AddControls ()

        Dim Txt As TextBox = New TextBox
        Txt.Name = "Txt1"
        Txt.Top = 10
        Txt.Left = 10
        Txt.Visible = True
        Me.Controls.Add(Txt)
        AddHandler Txt.TextChanged, AddressOf txtTextChanged

End Sub

 Private Sub txtTextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        MsgBox(sender.text)
 End Sub


Similarly you can go on Adding the Controls and Add their event handlers on the same form
since there certainly will be more than one control you need a logic to place the control i.e. the Top & Left property. You can decide to let it go in a flow layout way or whatever suits you. Also there can be a separate handler for each control or you can have the same Handler, In case of same Handler you can distinguish based on the Sender.name

0
 

Author Comment

by:m9s999
ID: 12304335
Great. I'll play around with it and see what I can do. Thanks.
0

Featured Post

Technology Partners: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question