We help IT Professionals succeed at work.
Get Started

Detect which controls are visible to the user

270 Views
Last Modified: 2013-11-26
I have a form that is laid out as in the attached file.

The information in the sub panels is retrieved through web services and is unfortunately quite slow - taking around a minute per 100 results to update fully.

Assume the large panel is called MainPanel and the smaller sub panels are called SubPanel(resultNumber).

The main panel can be scrolled up and down by the user whilst the detail in the sub panels are populating. A user can typically fit around 15 sub panels on the screen at a time.

How can I detect what sub panels are visible to the user after they scroll?

I wish to do this so that I can populate the panels on the screen (ie visible to the user) as a priority.

 
Sub createPanels(byVal results as Array)

Dim NumberOfResults as integer = results.length
Dim SubPanel(NumberOfResults) as Panel

For resultNumber = 0 to NumberOfResults - 1

SubPanel(resultNumber) = new Panel

With SubPanel(resultNumber)
     .BorderStyle = BorderStyle.Fixed3d
     .Dock = DockStyle.Top
     .Height = 60
End With


' Code to add labels etc from results array to the SubPanel
'
' At the moment the call to webservices is in here as well,
' although this is asynchronous and triggers an event when the call is
' complete allowing me to use this data on my SubPanels when it becomes 
' available. I will move these calls to a new sub allowing only 15 requests 
' at a time but I need to know which panels are onscreen in order to 
' prioritise which ones are to be updated next. 

MainPanel.Controls.Add(SubPanel(resultNumber))

' There are several controls that can be clicked on each SubPanel so we add 
' a handler
AddHandler SubPanelItem(resultNumber).Click, AddressOf PanelItemClicked 

Next

End Sub

Open in new window


Form Layout
Comment
Watch Question
Staff Software Engineer
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 2 Answers and 4 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE