How do I check on the ListView, if I click on index 0 (top) then my button will be enabled, but if I click other than index 0 (1, 2, 3, …) the button will be disabled (i.e., Enabled = false).
This is my current code:
private void lstAntrianPasien_SelectedIndexChanged(object sender, EventArgs e)
{
if (lstAntrianPasien.SelectedItems.Count > 0)
{
btnUbahStatus.Enabled = true;
}
else
{
btnUbahStatus.Enabled = false;
}
}
You can use the SelectedIndices property:
Alternately, if you want the button to be enabled if the first item is selected, regardless of the selection state of the other items, you can use Contains():