2.7 :childindex()

This method is used to calculate the absolute index of a child in a treeview. For this purpose the relative index of the child in relation to its parent is passed on to this method.

Definition

integer :childindex
(
  integer Parent input,
  integer Child  input
)

Parameters

integer Parent input
In this parameter the index of a parent is specified.
integer Child input
In this parameter the index in relation to the relevant parent is specified.

Return value

0
if error occurred
> 0
absolute index of child

Objects with this method

treeview

Example

window Wn
{
  .title "Example for method :childindex()";
  child treeview Tv
  {
    .content[1] "Company A";
    .content[2] "Miller";
    .content[3] "Meyer";
    .content[4] "Company B";
    .content[5] "Davis";
    .content[6] "Smith";
    .content[7] "Fisher";
    .style[style_lines]   true;
    .style[style_buttons] true;
    .style[style_root]    true;
    .level[2] 2;
    .level[3] 2;
    .level[5] 2;
    .level[6] 2;
    .level[7] 2;
  }

  child pushbutton PbIn
  {
    .text "Define absolute number";
    on select
    {
      variable integer I := Tv:childindex(Tv.activeitem, atoi(EtIn.content));

      if fail(atoi(EtIn.content)) then
        St.text := "Have you indicated a person?";
      endif
      if (I = 0) then
        St.text := "Have you selected a company?";
      else
        St.text := itoa(I);
      endif
    }
  }

  child edittext EtIn
  {
    .content   "Which person of the selected company is this?";
    .multiline true;
  }

  child statictext St
  {
    .text "Result of query";
  }
}