So i can't edit any columns in the DGV. Even when i set ReadOnly to 'False'. Some of my columns i don't want the users to edit the data but i want to be able to select the checkbox and i cant :(.. When i was debugging my code any of the columns i have set to ReadOnly = 'True' they are still coming accross as 'False' but i still cant click or edit anything!! Any tips on how to get around this? Spent far to long on this silly problem :(
So i want to just be able to tick the CheckBox, and i cannot do this for some reason.
sqlConnection.Open();
MessageBox.Show("Database " + strDatabase + " opened
successfully.");
string sqlSelectCompanies = "SELECT data, moreData, moreData1, moreData2 " +
"FROM tblClient INNER JOIN tbl ON tbl = tbl WHERE Serverid >=1"); //I cant show all details of the query
SqlCommand sqlCommand = new SqlCommand(sqlSelectCompanies, sqlConnection);
SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand);
sqlDataAdapter.Fill(companyDataSet, "Companies");
dataGridViewCompanies.DataSource = companyDataSet;
dataGridViewCompanies.DataMember = "Companies";
dataGridViewCompanies.ReadOnly = true;
//dataGridViewCompanies.Columns[0].ReadOnly = true;
//dataGridViewCompanies.Columns[1].ReadOnly = true;
//dataGridViewCompanies.Columns[2].ReadOnly = true;
//dataGridViewCompanies.Columns[3].ReadOnly = true;
//Enabling multiple row selection
dataGridViewCompanies.MultiSelect = true;
dataGridViewCompanies.SelectionMode =
GridViewSelectionMode.FullRowSelect;
this.dataGridViewCompanies.AllowSearchRow = true;
dataGridViewCompanies.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
dataGridViewCompanies.EnableGrouping = false;
GridViewCheckBoxColumn gvCheck = new GridViewCheckBoxColumn();
gvCheck.Name = "Select Company";
dataGridViewCompanies.MasterTemplate.Columns.Add(gvCheck);
dataGridViewCompanies.Columns[4].HeaderText = "Select Company";
//dataGridViewCompanies.MasterTemplate.Columns[4].ReadOnly = false;
//dataGridViewCompanies.Columns[4].OwnerTemplate.AllowEditRow = true;
dataGridViewCompanies.Columns[4].ReadOnly = false;
Aucun commentaire:
Enregistrer un commentaire