Disable checkbox checked in listview

1

I added in my ListView the default% of it "ListView Checkboxes", when it is checkbox I need to disable it so that it can no longer be "checked", I tried to make checked checkbox , but I could not access it, it is trying to access by the Enable false property.

    private void Form1_Load(object sender, EventArgs e)
    {
        ColumnHeader header = new ColumnHeader();
        header.Text = "NOME";
        header.Width = 415;
        header.TextAlign = HorizontalAlignment.Center;
        listView1.View = View.Details;
        listView1.GridLines = true;
        listView1.CheckBoxes = true;
        listView1.Columns.Add(header);


        for (int i = 0; i <= 10; i++ )
        {
            listView1.Items.Add(new ListViewItem(new string[] { "NOME_" + i }));
        }
    }

    private void listView1_ItemChecked(object sender, ItemCheckedEventArgs e)
    {
        if (e.Item.Checked == true)
        {
            MessageBox.Show("CheckBox Checked");

            //Aqui preciso desabilitar o CheckBox que foi Checked pra que não possa ser mais UnChecked
            //ou desbilitar a row inteira
        }

    }

    
asked by anonymous 28.08.2014 / 23:38

1 answer

0

Use the ItemCheck event that will have the desired effect (that is, it will be simulated like this, since this object could not change its status if it is already checked), where after setting it checked it can not be checked . Remembering that there is no Enabled in this component.

private void listView1_ItemCheck(object sender, ItemCheckEventArgs e)
{
      if (e.CurrentValue == CheckState.Checked)
      {
          e.NewValue = CheckState.Checked;
      }
}
    
31.08.2014 / 16:51