Reverse checkbox c#

Asked

Viewed 49 times

-1

I have this code.

You’re reading my checkboxes from top to bottom when they’re all checked. But what I needed was, when he started reading, I wanted him to start reading from 2.9.15 up. Not 2.9.16 down..

inserir a descrição da imagem aqui

foreach (UltraListViewItem item in listView.Items)
{
    if (item.CheckState == CheckState.Checked)
    {
        DataTable versionToUpdateDT = mUpdater.GetVersionToUpdate((int)item.Tag);
        mVersionSelect = item.Text;
    }    
}

I don’t know if that’s possible.

  • Ana, you want to, for example, when marking the CheckBox 2.9.15.1 all above it are marked?

1 answer

2


Yes it is possible, but not using foreach. In this case, use the command for:

for (int x = listView.Items.Count-1; x >= 0; x--)
{
     UltraListViewItem item = listView.Items[x];
     // aqui continua o seu código
}
  • I tried to do this and this message appears :The index was out of range. It has to be non-negative and smaller than the collection size. r nName of parameter: index"}

  • @Anacarvalho, updated the code, missed -1 on count

  • I got it. Thank you very much :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.