StrataFrame Forum

strataListView(Index was outside the bounds of the array)

http://forum.strataframe.net/Topic26917.aspx

By Jocelyn Dagrain - 4/19/2010

Bonjour
using the strataListView I am trying to disable and enable some toolstrip button
when I lost focus of the strataListView I received this error message (Index was outside the bounds of the array)
can you help me please thank you.

private void strataListView1_SelectedItemChanged(object sender, EventArgs e)
        {
           
            if (strataListView1.SelectedItems[0].Selected == true)
            {
                this.toolStripButtonEdit.Enabled = true;
                this.toolStripButtonDelete.Enabled = true;
            }
            else
            {
                this.toolStripButtonEdit.Enabled = false;
                this.toolStripButtonDelete.Enabled = false;
            }
         }

NB. With the standard strataframe listview I used this code

  private void listView_SelectedIndexChanged(object sender, EventArgs e)
        {

            this.toolStripButtonEditGroup.Enabled = listView.SelectedItems.Count > 0;
            this.toolStripDeleteGoup.Enabled = listView.SelectedItems.Count > 0;

        }

By Dustin Taylor - 4/20/2010

You can use something similar to what you did for the standard listview, you just reference GetLength(0) rather than Count:

this.toolStripButtonEditGroup.Enabled = strataListView1.SelectedItems.GetLength(0) > 0;
this.toolStripDeleteGoup.Enabled = strataListView1.SelectedItems.GetLength(0) > 0;

Hope it helps Smile

By Jocelyn Dagrain - 4/20/2010

Thank you very much It work fine

Just wandering is it normal that I cannot navigate within the stratalistview using the key board up and down arrow

Merci.

By Dustin Taylor - 4/20/2010

Yes, for now Smile. The StrataListView is still being enhanced, and that is simply one of the features that hasn't made it into it yet, though it will be there before the "final" release.