Click here to Skip to main content
15,890,947 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have this code,
C#
DataTable dataTable = new DataTable("Employees");

DataColumn[] columns = {
                            new DataColumn("EmployeeId", typeof(int)),
                            new DataColumn("EmployeeName", typeof(string)),
                            new DataColumn("Included", typeof(bool)),
                            new DataColumn("Role", typeof(Image))

                        };

dataTable.Columns.AddRange(columns);
dataTable.PrimaryKey = new DataColumn[] { dataTable.Columns["EmployeeId"] };

foreach (KeyValuePair<string, Employee> employee in employees)
{
    DataRow row = dataTable.NewRow();
    row["EmployeeId"] = employee.Value.ID;
    row["EmployeeName"] = string.Format("{0} {1}", employee.Value.FirstName, employee.Value.LastName);
    row["Included"] = employee.Value.IsSelling == true ? true : false; // This is where I check or uncheck the checkbox in the gridview. But how do I disable it when its false?
    row["Role"] = employee.Value.IsSelling == true ? CreateBitmapImage("[Selling]", 32, 77, 106) : GUI.Properties.Resources.employee_disabled_icon;

    dataTable.Rows.Add(row);
}

this.dataGridView_EmployeeSales.AutoGenerateColumns = false;
this.dataGridView_EmployeeSales.DataSource = dataTable;

Can I use a DataTable to disable that cell?

What I have tried:

Redirect Notice[^]Redirect Notice[^]
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900