FirstVisibleItem takes an Index, not a string. The Index is zero-based, as
Dave said. The points are

a) if you want a specific entry to be selected by default, so that the user
can change is if she wants and leave it if she doesn't, then you want
$LB->Select(), not FirstVisibleItem.

b) use $LB->FirstVisibleItem($LB->SelectedItem()) to make sure the selected
entry is not scrolled out of view.

c) if you sort the entries in your listbox, $LB->Select(0) does not select
the item you inserted first, but the first item in the sort order.

d) user $LB->FindString($entry) to get the zero-based index of $entry, for
use in other methods like Select of FirstVisibleItem.

Have fun,
Harald

> -----Original Message-----
> From: Dave [mailto:[EMAIL PROTECTED]
> Sent: Sonntag, 3. Juni 2001 06:04
> To: perl-win32-gui-users@lists.sourceforge.net
> Subject: RE: [perl-win32-gui-users] showing firstvisible in a 
> combo box
> 
> 
> I'm not sure this is the best way, but what I would do is change 
> 
> $bftextdecdd->FirstVisibleItem();
> to
> $bftextdecdd->Select(0);
> 
> That will automatically select the first element in your list.
> ( it is 0 because combobox uses a 0-based index to reference the items
> in the list ).
> 
> 
> Hope that helps.
> 
> Dave McLaughlin
> [EMAIL PROTECTED]
> 
> 
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of
> Chris Etzel
> Sent: Sunday, June 03, 2001 1:56 AM
> To: perl-win32-gui-users@lists.sourceforge.net
> Subject: [perl-win32-gui-users] showing firstvisible in a combo box
> 
> 
> Hey,
> 
> I have this code, and I want to make the word 'none' from the list
> visible by default and then the user can choose something else if they
> want. I have looked through the docs and have tried 
> FirstVisibleItem but
> no luck. Any help appreciated!
> 
> Chris
> 
> $bftextdecdd=$Win1->AddCombobox(
>  -name=>"bftextdecdd",
>  -width=>100,
>  -height=>100,
>  -tabstop=>1,
>  -top=>242,
>  -left=>370,
>  -style=> WS_VISIBLE | WS_SCROLL | 3
>  );
> 
>       $bftextdecdd->InsertItem("none");
>     $bftextdecdd->InsertItem("blink");
>     $bftextdecdd->InsertItem("line-through");
>     $bftextdecdd->InsertItem("underline");
>     $bftextdecdd->InsertItem("overline");
>     #$bftextdecdd->FirstVisibleItem(); how the hell do I show 
> 'none' as
>     #first visible by default?
> 
>     sub bftextdecdd_Change{
> 
> $bftextdecdd->Text($bftextdecdd->GetString($bftextdecdd->Selec
> tedItem));
>      }
> 
> 
> 
> _______________________________________________
> Perl-Win32-GUI-Users mailing list
> Perl-Win32-GUI-Users@lists.sourceforge.net
> http://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
> 
> 
> _______________________________________________
> Perl-Win32-GUI-Users mailing list
> Perl-Win32-GUI-Users@lists.sourceforge.net
> http://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
> 

Reply via email to