mardi 2 juillet 2019

Creating CheckBox in ListView Column

I am working on Winforms. I want to create checkBox for every row (that means, a column full of checkbox - NOT IN FIRST COLUMN) in ListView.

So far I have seen ListView.CheckBoxes = True, which doesn't fulfill my requirement.

 public Replace()
        {
            InitializeComponent();
            listView1.View = View.Details;
            listView1.Columns.Add("", 2);
            listView1.Columns.Add("Sheet",-2,HorizontalAlignment.Left);
            listView1.Columns.Add("Replace",-2,HorizontalAlignment.Center);
            listView1.Columns.Add("Create a copy",-2,HorizontalAlignment.Center);
            foreach (var value in Global.ReplaceSheets)
            {
                ListViewItem lvItem = new ListViewItem();
                lvItem.SubItems.Clear();
              //listView1.CheckBoxes = true; makes checkboxes in first column
                lvItem.Checked = true;

                lvItem.SubItems.Add(value.ToString());
                lvItem.SubItems.Add("checkbox");
                lvItem.SubItems.Add("");
                listView1.Items.Add(lvItem);

            }

        } 

I expect to have control of adding checkbox to any of the column in Winforms.




Aucun commentaire:

Enregistrer un commentaire