Le 7 déc. 06 à 19:09 Soir, Michael a écrit:

Arnaud,
A quick question.
If I wish to obtain a reference to say control(i) in the tabpanel, will the code

"control(i).doSomethingNow" find the control, irrespective of which Tab it currently resides?

In fact, the control() is a property of the window. You can see in the Language Reference, under Window class, that Control is listed under "Properties".

So Control(i) returns any control on the window. But, to find a control in a specified tab, you may use the TabPanelIndex property of a control.

If you want only a control on a specific tab, you may try this:

RetLastControlArrayIndex
theControl as controlClass(as integer)

   if theControl is nil then
  Return -1
  end if

  dim ParentWin as Window=theControl.Window
  dim N as integer=ParentWin.ControlCount-1
  dim LastIndex as integer= -1
  dim theControlName as string=theControl.Name
  dim Ctrl As Control

  for i as integer = 0 to N

    Ctrl=ParentWin.Control(i)
if Ctrl.Name=theControlName and Ctrl.TabPanelIndex=TabPanel1.Value then
      LastIndex=LastIndex+1
    end if
  next

  Return LastIndex

You change "TabPanel1.Value" to the panel you want if you don't always want the currently visible one.

I ask this as I am trying to loop through those specific controls in the window, and my is raising a nilobjectexception.

You may always detect a possible nil object before using it.

So, instead of:

Control(i).DoSomething

I'd suggest:

dim c As Control

c=Control(i)
if c<>nil then
c.DoSomething
end if

Maybe you are getting this NilObjectException because the controls in the array aren't always numbered by increment of 1? It can depend on your code.
Hope this helps_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to