Hi, I want to add a checkbox in the datagrid view. I have test code, but it does not work. What I'm trying to do is add a CheckBox to the datagrid with the elements that I add to it using the "Select All" and "No" buttons.
I do not know how to do this, so I need help. I am confused by the fact that if we add dynamically, how will we track which checkbox is checked or not checked.
I have current code
public partial class MainWindow : Window
{
List<checkedBoxIte> item = new List<checkedBoxIte>();
public MainWindow()
{
InitializeComponent();
for (int i = 0; i < 5; i++)
{
checkedBoxIte ite = new checkedBoxIte();
ite.sr = i.ToString();
ite.ch = new CheckBox();
item.Add(ite);
}
dataGrid1.ItemsSource = item
}
}
public class checkedBoxIte
{
public string sr {get;set;}
public CheckBox ch { get; set; }
}
but I know that this is the stupidest thing to add this flag, but it was just an attempt. Above the class contains two attributes later, it will have more, but all will have rows
source
share