[Gambas-user] Choose and nulls, a bug and a wish for a better way?

Benoît Minisini gambas at ...1...
Wed Aug 22 11:27:58 CEST 2012


Le 22/08/2012 05:50, Bruce a écrit :
> This almost works
>
>          grid[grid.Rows.Max, 15].Background =
>          IIf(IsNull(Choose(cs.Result, Color.Yellow, Color.Green,
>          Color.Cyan)), Color.Default, Choose(cs.Result, Color.Yellow,
>          Color.Green, Color.Cyan))
>
> (where grid is a gridview control (which just happens to have a column
> 15))
>
> cs.result is an integer value between 1 and 10.  As I load each of the
> gridview rows I'd like to highlight cells (in column 15) where the
> cs.result value is 1 or 2 or 3.
>
> The code is unwieldy because Choose returns a null if the choose value
> is not selectable from the list.
>
>          <WISH> It would be nice if there was some way to include a
>          default value if the choose value was not indexable.  Something
>          like
>
>          grid[grid.Rows.Max, 15].Background = Pick(cs.Result,
>          [Color.Yellow, Color.Green, Color.Cyan],Color.Default)
>
>          ie Pick(Value as Integer,List as Variant[],Optional Default As
>          Variant) As Variant
>          </WISH>
>
>
> But I digress.  Today's irk is demonstrated in the attached project that
> just loads a sample gridview using the unwieldy code above.  What has
> happened when the Choose value is 4????
>
> There are some comments in the code that may provide some insight.
>
> best regards
> Bruce
>
>
> p.s. Sorry, I cant post this to Issues as I am running a huge db re-org
> today and starting firefox grabs too much memory and kills the re-org
> task.
>

I won't do your wish, but the bug is fixed in revision #5068!

Regards,

-- 
Benoît Minisini




More information about the User mailing list