[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Best way to 'search' controls on a panel

Posted on 2007-11-30
6
Medium Priority
?
202 Views
Last Modified: 2010-04-23
I have a form's tab that displays a table.
In that table, I will have x number of rows.
On each row, I'll have a checkbox, and two combos.  The names of each are very similar but unique to any additional rows.

I now have my code displaying these and functioning the way I want, so it's time to take the data there and drop it into a database.

My problem: determining the best way to get at those controls and the data the contain...
I have two ideas so far, but wanted to know the more efficient route to take.
   Loop through all controls on the panel? (I will have a class-level counter variable to determine how many rows)
   Setup a 'hidden' control that would hold the primary name (that all 3 controls in a row are based off of)
   Or, some other ingenious method? :^)
   
0
Comment
Question by:sirbounty
[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
  • 3
  • 3
6 Comments
 
LVL 67

Author Comment

by:sirbounty
ID: 20381480
This is the approach I have taken so far, and it seems adequate, so I'm just looking for confirmation from those more versed in .Net that I'm using the right approach...
If I can get the checkbox name, then I will have the two combo's names.
For Each ctl As Control In tlpAppts.Controls
  If TypeOf (ctl) Is CheckBox Then
  

Open in new window

0
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 1000 total points
ID: 20381596
The code snippet you posted is correct and the usual solution, but notice some controls are inside other controls. By example your panel can contain a GroupControl that contains many controls. In that case you will need an extra nested For..Each loop.
0
 
LVL 67

Author Comment

by:sirbounty
ID: 20381684
In this case, it's just the run-time created table.  Besides the checkbox and combos, I'll have two buttons, and that'll be it.
0
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!

 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20381725
To extend my comment:
For Each ctl As Control In tlpAppts.Controls
        If TypeOf (ctl) Is GroupBox Then
              For Each ctl1 As Control In ctl.Controls
                     If TypeOf (ctl1) Is CheckBx Then
                       ' call function to process control
                     End If
              End For
        End If
End For

Open in new window

0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20381740
Then the code snippet you posted is OK
0
 
LVL 67

Author Comment

by:sirbounty
ID: 20381805
Easy 250 for you then mate.
Thanx again for the help! :^)
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

656 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