-2

Is it possible to bind a ListViewItem mode TwoWay to a ListView? (please an example) I found nothing about that on the Internet.

sorry for my bad English....

XardasLord
  • 1,764
  • 2
  • 20
  • 45

1 Answers1

0

In general, adding items to listview is something like that

you can also

        GridView grid = new GridView();
        grid.Columns.Add(new GridViewColumn { Header = "Id", DisplayMemberBinding = new Binding("Id") });
        grid.Columns.Add(new GridViewColumn { Header = "File", DisplayMemberBinding = new Binding("FileName") });
        grid.Columns.Add(new GridViewColumn { Header = "Status", DisplayMemberBinding = new Binding("Status") });
        FilesList.View = grid;


        ListViewItem viewItem = new ListViewItem();
        viewItem.Content = new MyItem { Id = 1, FileName = "test", Status = SignStatus.NotSigned };
        FilesList.Items.Add(viewItem);

this is MyItem definition

public class MyItem
{
    public int Id { get; set; }
    public string FileName { get; set; }
    public SignStatus Status { get; set; }
}

If you want to get item from listview

int index = 0; //some index
MyItem item = (MyItem)FilesList.Items[index];
/* change something for ex. 
 * item.id = 54;
 */
FilesList.Items.Refresh();
Kolkil Kolk
  • 156
  • 1
  • 10